Skip to content

Add CSS sprite to @tabler/flags - #16

Merged
codecalm merged 1 commit into
mainfrom
flags-css-sprite
Oct 19, 2026
Merged

codecalm merged 1 commit into
mainfrom
flags-css-sprite

Conversation

@codecalm

Copy link
Copy Markdown
Member

Summary

  • Adds a CSS sprite to @tabler/flags: dist/sprite/flags.svg packs all 297 flags into one 20x15 grid, and dist/sprite/flags.css shows one flag per element with background-position.
  • Every flag gets .flag-<slug> and .flag-<iso> classes. Aliases such as flag-sj reuse the cell of the flag they point to.
  • Positions are percentages, so one class works at any size. .flag-rounded adds the corners and border of the rounded variant with plain CSS instead of a second sprite.
  • dist/sprite/flags.json lists the pixel offset of every cell for custom CSS. Documented in both READMEs, with a minor changeset.

Preview

  • How to test: run pnpm build:flags, then open a page with <link rel="stylesheet" href="packages/flags/dist/sprite/flags.css"> and <span class="flag flag-rounded flag-pl"></span>. Change font-size on the span and check the flag scales. Compare flag-sj with flag-no.

Notes / rollout

  • The sprite file is about 412 KB and ships inside @tabler/flags, so the package tarball grows by that much.
  • Adding a flag appends a cell at the end of the grid. Users must update flags.svg and flags.css together.

Pack every source flag into dist/sprite/flags.svg and emit flags.css with
a .flag-<slug> / .flag-<iso> class per flag, plus flags.json with cell
offsets. Aliases reuse the cell of the flag they point to.
@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tabler-flags Ready Ready Preview Oct 19, 2026 8:06pm UTC

Request Review

@codecalm
codecalm merged commit 2c204ea into main Oct 19, 2026
12 checks passed
@codecalm
codecalm deleted the flags-css-sprite branch October 19, 2026 20:10
@github-actions github-actions Bot mentioned this pull request Oct 19, 2026

This branch was successfully deployed

1 active deployment
Preview — 366ae33f Deployed Oct 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant