Skip to content

Class names

What each TaishoDS Core class is called and why: the grammar, the modifiers, and the ts scope class.

The grammar

A class name is predictable. It takes one of two forms:

  • ts-property-value (sometimes with an axis in the middle: ts-property-axis-value). The property comes from a closed list and maps to a single CSS property, or to a shorthand with its longhands.
  • ts-word, a single word, only if it’s a value of display, position, visibility, or text decoration (flex, absolute, underline), plus a few one-off cases.

To read a class, you look for the longest prefix on the list—never split it at the hyphens. select, gap-x, and ring-shadow are whole prefixes. Components follow ts-root or ts-root-part. The full list of utilities, with their CSS, is in Utilities.

Class What it does
ms-halfmargin-inline-start at the half rhythm step
p-2424px of padding (an integer is always px)
mb-neg-1negative margin-bottom (neg- goes before the value)
border-b-2-gray-10002px bottom border in gray-1000 (a compound width-color value)
grid-cols-3three columns
radius-lgborder-radius at size lg
flexdisplay: flex (single word)
hiddendisplay: none (single word)
buttona component

Sizes. Integers are pixels (p-24 is 24px), and the rhythm words (none, quarter, half, base, section, double) change with density. They’re two different intentions, and they coexist.

Variants go before the colon and don’t change the name, as in md:hidden for a screen size, @md:gap-base for the container width, or hover:bg-gray-200 for a state. You can chain them (md:hover:bg-gray-200) in a fixed order. The closed list is in Variants, and the list of screens is in Responsive.


Negative margins

A negative margin takes neg- before the value: mt-neg-16 is margin-top: -16px. There’s no minus sign and no suffix—the name follows the same grammar as the positive margin. They exist on all seven sides (m, mx, my, mt, mb, ms, and me) and with the same values as the regular margin: the integers on the pixel scale (mx-neg-8) and the rhythm words, from quarter to double (mx-neg-base). none and 0 don’t take neg-, because a negative zero margin is zero.

Class What it does
m-neg-8-8px margin on all four sides
mx-neg-basenegative horizontal margin at the base rhythm step; it shrinks with the compact density
my-neg-8-8px vertical margin (top and bottom)
mt-neg-16-16px margin-top
mb-neg-16-16px margin-bottom
ms-neg-16-16px margin-inline-start: follows the reading direction (RTL)
me-neg-16-16px margin-inline-end: follows the reading direction (RTL)

They let a block break out of its container’s padding: a band or an image that spans the full width of a card that has p-base. Cancel the padding with the same value on the negative side (mx-neg-base undoes p-base).

html

Easy to confuse

Some pairs read alike and do different things. In each one, the difference is in the property, not the number.

Class What it does
text-14only the font size (font-size)
type-heading-14compound: font, line height, and letter spacing for a 14 heading
Class What it does
p-baserhythm: a word from the scale that changes with density
p-16fixed size: 16px at any density
Class What it does
align-centercenters the text (text-align)
items-centercenters the children of a flex or grid container (align-items)

Modifiers

Classes like variant-primary, size-sm, is-active, has-icon (the variant-*, size-*, is-*, and has-* families, among others) are short and don’t take ts-. They have one condition. They only apply when combined with the component’s base class, on the same element.

html
<button class="ts button variant-primary size-sm">Save</button>

A variant-primary or an is-active in your app, without the base, picks up no system styles. That’s why you can have your own classes with those names without them clashing.


The ts class

Classes are written flex, button, p-base, and the element also gets the ts scope class. Every CSS rule is emitted behind :where(.ts), so nothing in the system touches elements that don’t have it. It works the same from the CDN, with taisho generate, and with the Svelte component package.

html

Your own utilities

The ones you declare in taisho.config.ts are composed with those same short names.

ts

What to know

  • The ts class goes on the same element. An element with a system class but no ts gets no styles, and no error. The ts class on a container doesn’t reach its children. On a Svelte component tag (<Button>), the component adds it.
  • ts belongs to the system. If your app already uses a class with that name, they clash. Your own utilities can’t be called ts or share a short name with the system.
  • Specificity is that of one class. :where() adds nothing, so one of your single-class rules beats the system if it comes later in the same layer, and an unlayered one always beats the system CSS, which lives in layers.
  • The reset is global. What goes in @layer base (*, html, body, button…) isn’t behind the ts class and applies to the whole page.
  • Core’s JS creates its classes with ts. The class that compacts a subtree is called compact, and it carries ts too.