Design system/Components
Badge, pill, and switch
A badge labels something, a pill is a control that selects, and a switch turns something on and off. They look alike, but they do different jobs.
In codeapp/globals.css (.pill, .badge-soft, .badge-accent, .badge-count, .toggle)
Badges
badge-soft is a quiet label: "Soon", file type, status. badge-accent is for something that must be seen, like "New". badge-count is the unread counter, red and round, and shows only when the number isn't zero.
Pills
A pill is a control, not a heading: filter bars and view switchers are built from it. It's 30px tall, the same height as btn-sm, so a bar of pills next to buttons reads as one family. The active pill turns charcoal.
Sizes
min-height 30px · 12.5px / 500Touch inside main: 42px2px 8px · 10.5px / 600 · r 62px 7px · 10px / 700 · r 619px · 10.5px / 700 · pill36 × 21pxHandle 16px, spring 0.28sRules
Do
Badges for labels, pills for choices.
Don't
A tappable badge; no one knows it can be tapped.
Do
A switch for a setting that applies immediately.
Don't
A switch in a form with a Save button; a checkbox or a picker is better.
<span className="badge-soft">{tr("بهزودی")}</span>
<button className={`pill ${on ? "pill-active" : ""}`} onClick={toggle}>{tr("امروز")}</button>
<button className="toggle" data-on={enabled} onClick={flip} aria-pressed={enabled} />Size at each breakpoint
min-height 30px · padding 5px 12px · gap 5pxmin-height 34px · padding 8px 14px · 13.5pxmin-height 42pxOnly button and amin-height 40px · 13.5pxpadding 3px 9px · 11.5pxpadding 3px 8px · 11px46 × 27px · handle 21px::before inset -12px -8pxStates
translateY(-1px)Only .pill:is(button)scale(0.94).pill-active · --dark-contrast on --darkdata-on="true" · --accent · translateX(15px)Touch 19pxHandle 16 → 20pxOn: translateX(11px)2px solid var(--accent) · offset 2pxopacity 0.45 · not-allowedbackground 0.2s easeContrast and accessibility
4.64 : 1 · 5.33 : 1--text-secondary on --muted; AA12.94 : 1 · 14.62 : 1AAA5.19 : 1 · 5.19 : 1#fff on --accent-strong; 10px/700; AA5.14 : 1 · 5.54 : 1#fff on --red-strong; AA1.37 : 1 · 1.46 : 1Track on card; white knob with a shadow- Badges are short, bold text whose meaning is in the word, not just the color; the text of every badge, badge-soft included, now meets AA in both themes.
- .toggle is a <button>; state its state with aria-pressed (or role="switch" and aria-checked), because data-on tells a screen reader nothing.
- The switch doesn't mirror in right-to-left: on means the knob is on the right, in both directions.
- On touch screens, the switch's touch area is enlarged by an invisible ::before, 12px above and below and 8px on each side: about 62 by 51px.
Related pages