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 ofdisplay,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-half | margin-inline-start at the half rhythm step |
| p-24 | 24px of padding (an integer is always px) |
| mb-neg-1 | negative margin-bottom (neg- goes before the value) |
| border-b-2-gray-1000 | 2px bottom border in gray-1000 (a compound width-color value) |
| grid-cols-3 | three columns |
| radius-lg | border-radius at size lg |
| flex | display: flex (single word) |
| hidden | display: none (single word) |
| button | a 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-base | negative 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).
<article class="ts flex flex-col gap-base p-base radius-lg bg-gray-100">
<h3 class="ts type-heading-20">Annual plan</h3>
<div class="ts mx-neg-base px-base py-half bg-gray-300 type-label-14-strong">Save two months</div>
<p class="ts type-copy-14">The band runs edge to edge across the card.</p>
</article>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-14 | only the font size (font-size) |
| type-heading-14 | compound: font, line height, and letter spacing for a 14 heading |
| Class | What it does |
|---|---|
| p-base | rhythm: a word from the scale that changes with density |
| p-16 | fixed size: 16px at any density |
| Class | What it does |
|---|---|
| align-center | centers the text (text-align) |
| items-center | centers 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.
<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.
<section class="ts flex gap-base p-double md:hidden">
<button class="ts button variant-primary size-sm">Save</button>
</section>Your own utilities
The ones you declare in taisho.config.ts are composed with those same short names.
// taisho.config.ts
import type { TaishoConfig } from '@taishods/core/generate';
const config: TaishoConfig = {
themes: { principal: { colors: { brand: '#4F46E5' } } },
fontFaces: [],
fonts: { sans: 'ui-sans-serif, system-ui, sans-serif' },
defaultStates: { success: '#16A34A', warning: '#D97706', info: '#2563EB', danger: '#DC2626' },
utilities: { 'card-hero': ['p-double', 'radius-lg'] }, // short names
};
export default config;What to know
- The
tsclass goes on the same element. An element with a system class but notsgets no styles, and no error. Thetsclass on a container doesn’t reach its children. On a Svelte component tag (<Button>), the component adds it. tsbelongs to the system. If your app already uses a class with that name, they clash. Your own utilities can’t be calledtsor 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 thetsclass and applies to the whole page. - Core’s JS creates its classes with
ts. The class that compacts a subtree is calledcompact, and it carrieststoo.