@codenhub/styles 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.es.md +9 -8
- package/README.md +8 -7
- package/README.pt-BR.md +9 -8
- package/dist/aesthetics/chunky-tile.css +1 -1
- package/dist/aesthetics/cyber.css +1 -1
- package/dist/aesthetics/glass.css +1 -1
- package/dist/aesthetics/index.css +2 -2
- package/dist/aesthetics/neobrutalism.css +1 -1
- package/dist/aesthetics/pixel.css +1 -1
- package/dist/aesthetics/sketch.css +1 -1
- package/dist/cli.js +358 -0
- package/dist/components.css +50 -2
- package/dist/index.css +50 -2
- package/dist/index.d.ts +1 -0
- package/dist/native.css +50 -2
- package/dist/palette.css +1 -1
- package/dist/purge/classes.json +1 -0
- package/dist/purge/index.css +50 -0
- package/dist/theme.css +2 -2
- package/docs/accessibility.md +46 -27
- package/docs/changelog/0.8.0.md +70 -0
- package/docs/changelog/0.9.0.md +40 -0
- package/docs/changelog/index.md +2 -0
- package/docs/es/accessibility.md +47 -28
- package/docs/es/index.md +4 -3
- package/docs/es/integrating/index.md +38 -10
- package/docs/es/integrating/tailwind.md +79 -8
- package/docs/es/integrating/without-a-bundler.md +157 -5
- package/docs/es/setup.md +43 -34
- package/docs/es/usage/aesthetics.md +20 -14
- package/docs/es/usage/buttons.md +6 -2
- package/docs/es/usage/composing.md +6 -2
- package/docs/es/usage/content-and-layout.md +10 -4
- package/docs/es/usage/customizing.md +46 -26
- package/docs/es/usage/feedback.md +5 -1
- package/docs/es/usage/forms.md +30 -5
- package/docs/es/usage/index.md +7 -3
- package/docs/es/usage/presets.md +92 -0
- package/docs/es/usage/solo.md +4 -2
- package/docs/es/usage/theming.md +29 -16
- package/docs/es/usage/tooltips.md +2 -2
- package/docs/index.md +3 -2
- package/docs/integrating/index.md +38 -10
- package/docs/integrating/tailwind.md +78 -7
- package/docs/integrating/without-a-bundler.md +156 -4
- package/docs/pt-BR/accessibility.md +47 -28
- package/docs/pt-BR/index.md +4 -3
- package/docs/pt-BR/integrating/index.md +38 -10
- package/docs/pt-BR/integrating/tailwind.md +79 -8
- package/docs/pt-BR/integrating/without-a-bundler.md +157 -5
- package/docs/pt-BR/setup.md +43 -34
- package/docs/pt-BR/usage/aesthetics.md +20 -14
- package/docs/pt-BR/usage/buttons.md +6 -2
- package/docs/pt-BR/usage/composing.md +6 -2
- package/docs/pt-BR/usage/content-and-layout.md +10 -4
- package/docs/pt-BR/usage/customizing.md +46 -26
- package/docs/pt-BR/usage/feedback.md +5 -1
- package/docs/pt-BR/usage/forms.md +30 -5
- package/docs/pt-BR/usage/index.md +7 -3
- package/docs/pt-BR/usage/presets.md +92 -0
- package/docs/pt-BR/usage/solo.md +4 -2
- package/docs/pt-BR/usage/theming.md +22 -9
- package/docs/pt-BR/usage/tooltips.md +2 -2
- package/docs/setup.md +31 -22
- package/docs/usage/aesthetics.md +19 -13
- package/docs/usage/buttons.md +5 -1
- package/docs/usage/composing.md +5 -1
- package/docs/usage/content-and-layout.md +9 -3
- package/docs/usage/customizing.md +45 -25
- package/docs/usage/feedback.md +4 -0
- package/docs/usage/forms.md +29 -4
- package/docs/usage/index.md +6 -2
- package/docs/usage/presets.md +91 -0
- package/docs/usage/solo.md +3 -1
- package/docs/usage/theming.md +21 -8
- package/docs/usage/tooltips.md +1 -1
- package/llms-full.txt +695 -134
- package/llms.txt +3 -2
- package/package.json +117 -65
- package/{dist/tw → tw}/aesthetics/chunky-tile.css +43 -20
- package/{dist/tw → tw}/aesthetics/cyber.css +19 -25
- package/{dist/tw → tw}/aesthetics/glass.css +110 -36
- package/{dist/tw → tw}/aesthetics/neobrutalism.css +41 -21
- package/{dist/tw → tw}/aesthetics/pixel.css +3 -0
- package/tw/aesthetics/sketch.css +435 -0
- package/{dist/tw → tw}/box.css +109 -26
- package/tw/components/button.css +11 -0
- package/tw/components/button.rules.css +187 -0
- package/tw/components/feedback.css +11 -0
- package/{dist/tw/components/feedback.css → tw/components/feedback.rules.css} +156 -33
- package/tw/components/form.css +11 -0
- package/{dist/tw/components/form.css → tw/components/form.rules.css} +584 -141
- package/tw/components/index.css +16 -0
- package/tw/components/rules.css +41 -0
- package/tw/components/surface.css +11 -0
- package/tw/components/surface.rules.css +225 -0
- package/tw/components/tooltip.css +11 -0
- package/{dist/tw/components/tooltip.css → tw/components/tooltip.rules.css} +82 -61
- package/{dist/tw → tw}/corner.css +18 -12
- package/{dist/tw → tw}/elevation.css +27 -21
- package/{dist/tw → tw}/index.css +11 -9
- package/tw/index.d.ts +1 -0
- package/tw/intent.css +312 -0
- package/tw/modifiers.css +127 -0
- package/tw/native.css +323 -0
- package/tw/presentation.css +139 -0
- package/tw/reset.css +10 -0
- package/{dist/tw/reset.css → tw/reset.rules.css} +7 -8
- package/tw/size.css +34 -0
- package/tw/surface.css +9 -0
- package/tw/surface.rules.css +212 -0
- package/{dist/tw → tw}/theme.css +93 -29
- package/tw/typography.css +8 -0
- package/{dist/tw/typography.css → tw/typography.rules.css} +0 -3
- package/{dist/tw → tw}/utilities/content.css +248 -108
- package/tw/utilities/index.css +11 -0
- package/tw/utilities/layout.css +210 -0
- package/tw/utilities/rules.css +8 -0
- package/dist/tw/aesthetics/sketch.css +0 -398
- package/dist/tw/components/button.css +0 -139
- package/dist/tw/components/index.css +0 -35
- package/dist/tw/components/surface.css +0 -184
- package/dist/tw/intent.css +0 -229
- package/dist/tw/native.css +0 -203
- package/dist/tw/palette.css +0 -460
- package/dist/tw/presentation.css +0 -68
- package/dist/tw/surface.css +0 -61
- package/dist/tw/utilities/index.css +0 -6
- package/dist/tw/utilities/layout.css +0 -144
- /package/{dist/tw → tw}/aesthetics/index.css +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Predefinições
|
|
3
|
+
description: Três formas de definir um visual uma única vez em vez de em cada elemento, e quando usar cada uma.
|
|
4
|
+
order: 11
|
|
5
|
+
source: 308b21076223635a3323bcfecb70abe3a9e6d1c7
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Predefinições
|
|
9
|
+
|
|
10
|
+
A esta altura, a tela de configurações diz `btn primary soft sm` em uma dúzia de lugares, e mudar de ideia significa mudar uma dúzia de lugares. Esta página trata das três formas de definir um visual uma única vez: classes de eixo em um contêiner, tokens de tema e de material, e as suas próprias classes de componente feitas com `@apply`. Cada uma serve para um tipo diferente de "uma única vez".
|
|
11
|
+
|
|
12
|
+
## Qual usar
|
|
13
|
+
|
|
14
|
+
| Você quer | Use |
|
|
15
|
+
| ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
16
|
+
| Que todos os componentes de uma região compartilhem um preenchimento, uma borda ou um material | [Classes de eixo em um contêiner](#classes-de-eixo-em-um-contêiner) |
|
|
17
|
+
| Outras cores, cantos, bordas ou profundidade para uma página ou uma região | [Tokens de tema e de material](#tokens-de-tema-e-de-material) |
|
|
18
|
+
| Um nome para uma receita que você repete, como "o botão de salvar" | [Suas próprias classes de componente](#suas-próprias-classes-de-componente) |
|
|
19
|
+
|
|
20
|
+
Elas se combinam. Uma região pode definir um token de material, ficar sob uma estética e conter a sua própria classe de botão, e cada elemento ainda pode sobrescrever o que herda.
|
|
21
|
+
|
|
22
|
+
## Classes de eixo em um contêiner
|
|
23
|
+
|
|
24
|
+
Algumas classes funcionam num contêiner além de num componente, e tudo dentro dele as recebe:
|
|
25
|
+
|
|
26
|
+
- As classes de apresentação: `.solid`, `.soft`, `.ghost`, `.edged` e `.edgeless`.
|
|
27
|
+
- Os padrões de canto: `.cut-diagonal` e `.cut-diagonal-reverse`.
|
|
28
|
+
- As [estéticas](./aesthetics.md), como `.glass` ou `.pixel`.
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<div class="cluster soft edged">
|
|
32
|
+
<button class="btn primary" type="button">Negrito</button>
|
|
33
|
+
<button class="btn" type="button">Itálico</button>
|
|
34
|
+
<button class="btn destructive solid" type="button">Limpar formatação</button>
|
|
35
|
+
</div>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Os botões da barra são soft e com borda, e o último pede o próprio preenchimento. Uma classe no elemento sempre vence a de um contêiner.
|
|
39
|
+
|
|
40
|
+
Os outros eixos não são herdados. A intenção, a elevação (`.flat`, `.raised`, `.floating`) e o tamanho (`.sm`, `.lg`) mudam só o elemento em que estão, então uma barra `.sm` não encolhe os seus botões; [Composição → Combinando classes](./composing.md#combinando-classes) explica por quê. Uma classe de estética também define o próprio padrão de canto na sua região, então um `.cut-diagonal` acima de uma região `.pixel` não chega dentro dela.
|
|
41
|
+
|
|
42
|
+
Use uma classe de contêiner quando o visual pertence à região, como uma barra lateral discreta, e não aos componentes dentro dela.
|
|
43
|
+
|
|
44
|
+
## Tokens de tema e de material
|
|
45
|
+
|
|
46
|
+
Tokens são propriedades personalizadas de CSS. Defina um no `:root` e a página inteira segue; defina num elemento e só o que está dentro segue. Eles vão mais longe que as classes, porque os componentes os leem enquanto são desenhados:
|
|
47
|
+
|
|
48
|
+
```css
|
|
49
|
+
.admin {
|
|
50
|
+
--radius-control: 0.25rem;
|
|
51
|
+
--radius-surface: 0.5rem;
|
|
52
|
+
--border-width: 2px;
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Todo botão, campo, balão de tooltip e superfície dentro de `.admin` recebe os cantos mais fechados e a borda mais grossa, sem classe em nenhum deles. Checkboxes, `.kbd` e `.code` mantêm o próprio canto menor, `--radius-small`.
|
|
57
|
+
|
|
58
|
+
As tabelas ficam onde os tokens são explicados, então esta página não as repete:
|
|
59
|
+
|
|
60
|
+
- [Temas → Tokens de cor](./theming.md#tokens-de-cor): cores de marca e de status, nos dois temas.
|
|
61
|
+
- [Temas → Tokens fundamentais](./theming.md#tokens-fundamentais): cantos, largura da borda, altura dos controles, anel de foco, profundidade e movimento.
|
|
62
|
+
- [Personalização → Tokens de apresentação](./customizing.md#tokens-de-apresentação): quanto um preenchimento, uma borda ou um hover acrescenta.
|
|
63
|
+
- [Personalização → Tokens de material](./customizing.md#tokens-de-material): o que uma estética define, e que você mesmo pode definir, como `--ui-radius`.
|
|
64
|
+
- [Personalização → Tokens de estética](./customizing.md#tokens-de-estética): os ajustes de cada estética, como `--neo-offset`.
|
|
65
|
+
|
|
66
|
+
Use tokens quando a mudança é um valor, como uma cor ou um canto, e não uma escolha entre classes.
|
|
67
|
+
|
|
68
|
+
## Suas próprias classes de componente
|
|
69
|
+
|
|
70
|
+
Com os entrypoints de código-fonte do Tailwind, todo componente, helper e classe de eixo é um utilitário do Tailwind, então uma classe sua pode carregar a receita inteira:
|
|
71
|
+
|
|
72
|
+
```css
|
|
73
|
+
@import "@codenhub/styles/tw";
|
|
74
|
+
|
|
75
|
+
@utility btn-save {
|
|
76
|
+
@apply btn primary soft sm;
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<button class="btn-save" type="submit">Salvar alterações</button>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`btn-save` se comporta como `btn primary soft sm` escrito por extenso, com estéticas e hover incluídos, e mudar a receita muda todos os botões de salvar. Modificadores que pertencem a um componente, como `.tight` no `.stack` ou `.icon` no `.btn`, também são utilitários, então `@apply btn icon` dá a você um botão de ícone próprio. [Tailwind CSS v4 → Construa seus próprios componentes com `@apply`](../integrating/tailwind.md#construa-seus-próprios-componentes-com-apply) tem as regras, inclusive por que `@utility` é melhor que uma regra simples.
|
|
85
|
+
|
|
86
|
+
Com o CSS compilado não existe `@apply`. Mantenha a receita num único lugar do outro lado: um partial de template, um componente do seu framework ou uma constante como `const saveButton = "btn primary soft sm"`.
|
|
87
|
+
|
|
88
|
+
Use a sua própria classe quando a mesma combinação nomeia uma única coisa no seu design, como o botão de salvar ou o card de plano.
|
|
89
|
+
|
|
90
|
+
## A seguir
|
|
91
|
+
|
|
92
|
+
A página de [Acessibilidade](../accessibility.md) lista o que o CSS faz pelos seus usuários e o que a sua aplicação ainda deve a eles.
|
package/docs/pt-BR/usage/solo.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
title: Classes solo
|
|
3
3
|
description: Como aplicar uma estética a um único elemento de outra biblioteca, como um toast ou um dialog, e o que uma classe solo lê e ignora.
|
|
4
4
|
order: 7
|
|
5
|
-
source:
|
|
5
|
+
source: ed6b271ec9d3eb83dfc5f098f587d8fc0d5e2ad3
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Classes solo
|
|
@@ -77,7 +77,9 @@ Sem nenhuma dessas classes, uma classe solo desenha só o material (borda, canto
|
|
|
77
77
|
## Como ela vence e quando ela se move
|
|
78
78
|
|
|
79
79
|
- **Ela vence os estilos da outra biblioteca.** As regras são sem camada e têm uma classe de profundidade, então vencem as regras com camada de um componente, e as de especificidade zero, onde quer que as duas carreguem. Uma regra externa sem camada que seja mais específica, ou igualmente específica e posterior na página, ainda vence. O outro lado disso é que um utilitário do Tailwind no mesmo elemento, como `rounded-none`, perde para a classe solo: use os ajustes dela em vez disso.
|
|
80
|
-
- **Ela só faz clicar uma ação.** Neobrutalism, chunky tile e cyber afundam ao clicar um `button`, um `a[href]`, um `[role="button"]`, um `summary` ou um `input` do tipo botão que
|
|
80
|
+
- **Ela só faz clicar uma ação.** Neobrutalism, chunky tile e cyber afundam ao clicar um `button`, um `a[href]`, um `[role="button"]`, um `summary` ou um `input` do tipo botão a menos que tenha o atributo `disabled`, `.disabled`, `aria-disabled="true"` ou `data-disabled`. Só o atributo desabilita um botão; o clique ignora os outros três também, já que uma página os usa para marcar um botão que ela trata como desabilitado. Todo o resto fica parado, então um toast não afunda ao ser clicado. O rótulo mais pesado do chunky tile segue a mesma regra.
|
|
81
|
+
- **Ela não mexe no movimento de um contêiner.** Só uma ação recebe a `transition` do clique, e o clique move o elemento pelas propriedades `translate` e `scale`, não por `transform`. Um toast mantém as suas próprias transições e o seu próprio `transform`. Numa ação, a `transition` do clique substitui qualquer uma que o elemento tivesse.
|
|
82
|
+
- **O movimento reduzido mantém o clique e tira o movimento dele.** Com `prefers-reduced-motion: reduce`, neobrutalism, chunky tile e cyber ainda respondem ao clique, mas de imediato: o elemento pousa na sua sombra ou barra, ou encolhe, sem se deslocar até lá.
|
|
81
83
|
|
|
82
84
|
## A seguir
|
|
83
85
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
title: Temas
|
|
3
3
|
description: Modo claro e escuro, como trocar a paleta pelas cores da marca, como definir uma intenção própria, e cada token de cor, de intenção, fundamental e de fonte com o seu padrão.
|
|
4
4
|
order: 5
|
|
5
|
-
source:
|
|
5
|
+
source: b54ac4e817f35fb4f5f32b7f7022061f9658147a
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Temas
|
|
@@ -30,17 +30,26 @@ Uma tela de configurações com a escolha "Sistema / Claro / Escuro" remove o at
|
|
|
30
30
|
|
|
31
31
|
Como isso é resolvido:
|
|
32
32
|
|
|
33
|
-
- Um seletor de tema define a propriedade CSS `color-scheme` e
|
|
34
|
-
- `color-scheme` é herdado, então um seletor aplica o tema a tudo o que está dentro dele. Um seletor em qualquer elemento aplica o tema àquela parte da página: uma barra lateral escura numa página clara é `<aside class="dark"
|
|
33
|
+
- Um seletor de tema define a propriedade CSS `color-scheme` e a cor do texto do elemento como `--color-text`. Cada token de cor guarda o seu valor claro e o seu valor escuro ao mesmo tempo, por meio de `light-dark()`, e o `color-scheme` do elemento escolhe um deles.
|
|
34
|
+
- `color-scheme` é herdado, então um seletor aplica o tema a tudo o que está dentro dele. Um seletor em qualquer elemento aplica o tema àquela parte da página: uma barra lateral escura numa página clara é `<aside class="dark">`, e o texto dentro dela recebe a cor de texto do tema escuro.
|
|
35
|
+
- Um seletor não define fundo. Dê você mesmo o fundo da região, como `background: var(--color-background)`. Qualquer classe utilitária ou de componente no mesmo elemento substitui a cor de texto do seletor.
|
|
35
36
|
- O seletor mais próximo vence, em qualquer profundidade. Um card `.light` dentro de uma página `.dark` é claro.
|
|
36
37
|
- Sem seletor, a raiz tem `color-scheme: light dark`, que segue o sistema.
|
|
37
38
|
- Coloque um único tema por elemento. Se um elemento tiver um seletor claro e um escuro, o escuro vence, mas não conte com isso.
|
|
38
|
-
- Definir você mesmo o `color-scheme` num elemento
|
|
39
|
+
- Definir você mesmo o `color-scheme` num elemento aplica o tema aos tokens do mesmo jeito, porque ele é a única coisa que a paleta lê. Isso também aplica o tema a partes nativas, como barras de rolagem e o interior de controles de formulário. O texto simples dentro dele mantém a cor que herdou até você definir também `color: var(--color-text)`.
|
|
39
40
|
|
|
40
41
|
Toda cor de componente vem de um token ou de `currentColor`, então os componentes seguem o tema sem regras próprias de modo escuro. As marcas que o pacote desenha, como o visto do checkbox e a seta do select, também usam `currentColor`. Ícones e imagens que você adiciona ficam por sua conta.
|
|
41
42
|
|
|
42
43
|
`light-dark()` funciona a partir do Chrome 123, Safari 17.5 e Firefox 120. O pacote como um todo exige Firefox 128; veja [Configuração → Requisitos](../setup.md#requisitos).
|
|
43
44
|
|
|
45
|
+
### Impressão
|
|
46
|
+
|
|
47
|
+
Uma página é impressa no tema claro, seja qual for o tema que ela mostra na tela. Dentro de `@media print`, a raiz e todo seletor escuro definem `color-scheme: light`, então todo token é resolvido para o seu valor claro, inclusive o de uma barra lateral forçada para o escuro. O papel é claro, e texto escuro sobre ele gasta menos tinta do que uma página escura impressa.
|
|
48
|
+
|
|
49
|
+
Componentes preenchidos imprimem o seu fundo. Por padrão, o navegador tira os fundos de uma página impressa, o que deixa o texto de contraste de um botão sólido sobre o nada, então todo componente define `print-color-adjust: exact`. A propriedade é herdada, de modo que o conteúdo de um componente também mantém as suas cores.
|
|
50
|
+
|
|
51
|
+
Um limite: um utilitário `dark:` continua valendo na impressão. Ele casa pelo seletor, não pelo `color-scheme`, então com `<html class="dark">` e `dark:bg-black` num elemento, esse fundo sai preto no papel. Escreva um utilitário `print:` ao lado dele se a página impressa importar.
|
|
52
|
+
|
|
44
53
|
### A variante `dark:`
|
|
45
54
|
|
|
46
55
|
Com os entrypoints de código-fonte do Tailwind (`/tw`), o pacote substitui a variante `dark:` do Tailwind para que os seus próprios utilitários sigam o mesmo tema que os tokens. Um utilitário `dark:` se aplica sob um seletor escuro explícito no elemento ou num ancestral, ou sob uma preferência de sistema escura quando nenhum ancestral define um tema:
|
|
@@ -58,7 +67,7 @@ Com os entrypoints de código-fonte do Tailwind (`/tw`), o pacote substitui a va
|
|
|
58
67
|
|
|
59
68
|
Ela difere dos tokens em um caso: um tema explícito aninhado dentro do tema oposto. Um elemento `.light` dentro de um `.dark` tem tokens claros, porque o `color-scheme` mais próximo vence. Mas `dark:` casa por seletor, e `.dark *` casa com todo elemento dentro de `.dark`, então um utilitário `dark:` dentro daquele elemento `.light` ainda se aplica. Se uma página usa tanto tokens quanto utilitários `dark:`, não aninhe temas opostos.
|
|
60
69
|
|
|
61
|
-
Os entrypoints compilados não definem uma variante `dark:`; eles não têm um build do Tailwind em que defini-la.
|
|
70
|
+
Os entrypoints compilados não definem uma variante `dark:`; eles não têm um build do Tailwind em que defini-la. O [comando `chs build`](../integrating/without-a-bundler.md#variantes) oferece `dark:`, sim, com os mesmos seletores, só nas classes de intenção, apresentação e modificador.
|
|
62
71
|
|
|
63
72
|
## Mude a cor da marca
|
|
64
73
|
|
|
@@ -92,6 +101,8 @@ O mesmo padrão funciona para todas as famílias em [Tokens de cor](#tokens-de-c
|
|
|
92
101
|
|
|
93
102
|
Os valores precisam ser cores completas: hex, `rgb()`, `oklch()` ou uma variável que você mesmo declarou. Variáveis da paleta do Tailwind, como `--color-teal-700`, existem num build `/tw`, vindas do seu tema do Tailwind, mas o CSS compilado declara só as cores da paleta que o próprio pacote usa. Com CSS compilado, uma referência a qualquer outra variável da paleta fica vazia, e a cor que ela alimenta se perde.
|
|
94
103
|
|
|
104
|
+
Com `/tw`, você pode descartar os tons do Tailwind que o seu design não usa, para que `bg-red-500` e companhia deixem de ser classes. Mantenha os que o tema lê, `neutral`, `emerald`, `amber`, `rose`, `indigo` e `white`: apagados, as cores construídas a partir deles se perdem sem nenhum erro. [Tailwind CSS v4 → Descarte a paleta do Tailwind](../integrating/tailwind.md#descarte-a-paleta-do-tailwind) tem o bloco para copiar.
|
|
105
|
+
|
|
95
106
|
## Sua própria intenção
|
|
96
107
|
|
|
97
108
|
O pacote entrega seis intenções, `.primary`, `.secondary`, `.success`, `.warning`, `.destructive` e `.info`, mais o padrão, `.neutral`. Para adicionar uma, como uma cor "Beta" para funcionalidades em prévia, escreva uma classe que define os sete slots de intenção. Use cores completas, com `light-dark()` para tudo o que muda entre os temas:
|
|
@@ -121,6 +132,8 @@ A classe funciona em tudo o que aceita intenção: botões, badges, campos e tog
|
|
|
121
132
|
- **Um repouso discreto, sem tom.** Um `.card.soft`, um `.panel` e um `.alert` neutros ficam sobre o tom de fundo discreto, e só reconhecem uma intenção pelas seis classes embutidas. `.card.soft.beta`, `.panel.beta` e `.alert.beta` são desenhados como o neutro: o tom de fundo discreto em vez de um tom violeta. A sua intenção ainda colore o texto e a borda deles.
|
|
122
133
|
- **O tom dos chips.** Uma tecla `.kbd` ou um bloco de código `.beta` mostra o seu tom `--intent-subtle`, mas não os 12% extras de `--intent-color` que uma intenção embutida acrescenta por cima.
|
|
123
134
|
- **Classes solo.** Uma [classe solo](./solo.md) como `.neobrutalism-solo` só aceita intenção das seis classes embutidas, então `.neobrutalism-solo.beta` é desenhado como neutro.
|
|
135
|
+
- **O texto do hint.** Um [`.hint`](./forms.md#mostre-um-erro-de-validação) só aparece no tom legível de uma intenção com as seis classes embutidas, então `.hint.beta` continua na cor secundária.
|
|
136
|
+
- **Linhas de tabela.** Uma linha do corpo muda a cor do texto, da linha divisória e do hover só com as classes de intenção embutidas. `<tr class="beta">` fica igual ao resto da sua tabela.
|
|
124
137
|
|
|
125
138
|
Se você precisa disso, há dois caminhos:
|
|
126
139
|
|
|
@@ -233,7 +246,7 @@ As quatro sombras `--elevation-*` são para elementos que você mesmo estiliza.
|
|
|
233
246
|
| `--elevation-sm` | `0 1px 2px`, `0 1px 3px` | Uma sombra leve para as suas próprias superfícies, como um card. |
|
|
234
247
|
| `--elevation-md` | `0 4px 6px -1px`, `0 2px 4px -2px` | Uma sombra para os seus próprios elementos elevados, como um menu dropdown. |
|
|
235
248
|
| `--elevation-lg` | `0 20px 25px -5px`, `0 8px 10px -6px` | Uma sombra para as suas próprias sobreposições, como um dialog modal. |
|
|
236
|
-
| `--focus-ring` | `--color-primary` com 64% de opacidade
|
|
249
|
+
| `--focus-ring` | Não definido | Cor do anel de foco do teclado. Quando não está definido, `--color-primary` com 64% de opacidade, no elemento focado. |
|
|
237
250
|
| `--focus-ring-offset` | Não definido | Distância entre o anel e o elemento. Quando não está definido, o anel fica sobre a borda do elemento em qualquer estética. |
|
|
238
251
|
| `--focus-ring-width` | `3px` | Espessura do anel de foco do teclado. |
|
|
239
252
|
| `--motion-duration-fast` | `120ms` | O hover de uma linha de tabela. |
|
|
@@ -243,7 +256,7 @@ As quatro sombras `--elevation-*` são para elementos que você mesmo estiliza.
|
|
|
243
256
|
| `--z-popover` | `40` | Ordem de empilhamento dos balões de tooltip. Use nos seus próprios popovers para que eles empilhem do mesmo jeito. |
|
|
244
257
|
| `--breakpoint-xs` | `30rem` | O breakpoint responsivo `xs:`. Só num build `/tw`; os entrypoints compilados não o declaram. |
|
|
245
258
|
|
|
246
|
-
Cada sombra `--elevation-*` é composta das partes listadas, cada uma em `--elevation-color`. O passo de hover que intensifica um preenchimento sob o ponteiro é um token de apresentação, `--hover-step`; veja [Personalização](./customizing.md#tokens-de-apresentação).
|
|
259
|
+
Cada sombra `--elevation-*` é composta das partes listadas, cada uma em `--elevation-color`. As quatro sombras são compostas uma única vez, na raiz, então um `--elevation-color` que você define num contêiner não chega até elas: defina-o em `:root`, ou defina o próprio token `--elevation-*` no contêiner. As classes de elevação, como `.card.raised`, leem `--elevation-color` no elemento e seguem o valor de um contêiner, com uma exceção: toda classe de estética define o seu próprio `--elevation-color` na sua região. Um valor definido acima de uma região `.glass` ou `.pixel` não chega dentro dela. Defina-o no próprio elemento da estética, onde o seu utilitário ou CSS sem camada vence a classe, ou num elemento dentro da região. No glass, a sombra de uma superfície é montada no elemento `.glass`, então só um valor definido ali a muda. No `.neobrutalism` a sombra é desenhada na intenção ou na tinta, e o `.cyber` não desenha profundidade, então nenhum dos dois lê o token. O passo de hover que intensifica um preenchimento sob o ponteiro é um token de apresentação, `--hover-step`; veja [Personalização](./customizing.md#tokens-de-apresentação).
|
|
247
260
|
|
|
248
261
|
## Fontes
|
|
249
262
|
|
|
@@ -251,14 +264,14 @@ O pacote não entrega arquivos de fonte e não faz requisições de rede. Cada t
|
|
|
251
264
|
|
|
252
265
|
| Token | Lido por | Sem o seu valor |
|
|
253
266
|
| ---------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
254
|
-
| `--font-default` | O reset, em `html` e `body`.
|
|
267
|
+
| `--font-default` | O reset, em `html` e `body`, e as regiões `.glass` e `.neobrutalism`. Os controles o herdam. | `"Segoe UI", system-ui, sans-serif` |
|
|
255
268
|
| `--font-mono` | Os utilitários de conteúdo `kbd`, `code` e `pre`, e `<kbd>`, `<code>` e `<pre>` com `/native` | `ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`. Com `/tw`, o valor do seu tema do Tailwind. |
|
|
256
269
|
| `--font-pixel` | [`.pixel`](./aesthetics.md#pixel) e `.pixel-solo` | Não declarado. Cai numa pilha monoespaçada. |
|
|
257
270
|
| `--font-rounded` | [`.chunky-tile`](./aesthetics.md#chunky-tile) e `.chunky-tile-solo` | Não declarado. Cai em `--font-default` e, depois, numa pilha sans-serif. |
|
|
258
271
|
| `--font-cyber` | [`.cyber`](./aesthetics.md#cyber) e `.cyber-solo` | Não declarado. Cai numa pilha monoespaçada. |
|
|
259
272
|
| `--font-sketch` | [`.sketch`](./aesthetics.md#sketch) e `.sketch-solo` | Não declarado. Cai na família `cursive` da plataforma. |
|
|
260
273
|
|
|
261
|
-
`--font-default` só chega à página pelo reset, que `@codenhub/styles`, `/native`, `/tw`, `/tw/native` e `/tw/reset` incluem. Usando só `/theme` ou `/components`, defina você mesmo o `font-family` no `body`. Os tokens das estéticas são lidos pela classe da própria estética, então funcionam com qualquer entrypoint.
|
|
274
|
+
`--font-default` só chega à página pelo reset, que `@codenhub/styles`, `/native`, `/tw`, `/tw/native` e `/tw/reset` incluem. Usando só `/theme` ou `/components`, defina você mesmo o `font-family` no `body` e defina `--font-default` com a mesma fonte: as regiões `.glass` e `.neobrutalism` definem o próprio `font-family` a partir do token, então uma fonte definida só no `body` não chega dentro delas. Ou defina só o token e escreva `font-family: var(--font-default)` no `body`. Os tokens das estéticas são lidos pela classe da própria estética, então funcionam com qualquer entrypoint.
|
|
262
275
|
|
|
263
276
|
Para usar uma web font, carregue-a como você carrega qualquer fonte e depois nomeie-a no token. Defina o token no `:root` para a página inteira, ou em qualquer elemento para aquela parte dela:
|
|
264
277
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
title: Tooltips
|
|
3
3
|
description: Ajuda de campo que abre no hover e no foco, como ligá-la a leitores de tela e à tecla Escape, e onde um tooltip é cortado.
|
|
4
4
|
order: 4
|
|
5
|
-
source:
|
|
5
|
+
source: ac236b423d466ebd014b7738dd076ace2cfc50a3
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Tooltips
|
|
@@ -76,7 +76,7 @@ O WCAG 1.4.13 pede três coisas de um conteúdo que aparece no hover ou no foco.
|
|
|
76
76
|
- **Persistente.** Ele continua aberto até o ponteiro e o foco saírem.
|
|
77
77
|
- **Dispensável.** O usuário precisa conseguir fechá-lo sem mover o ponteiro nem o foco, normalmente com Escape. O CSS não consegue escutar uma tecla, então essa parte é sua.
|
|
78
78
|
|
|
79
|
-
Para mudar o tempo de permanência, defina `--tooltip-linger` no elemento `.tooltip
|
|
79
|
+
Para mudar o tempo de permanência, defina `--tooltip-linger` no elemento `.tooltip` ou em qualquer elemento em volta dele, por exemplo `style="--tooltip-linger: 500ms"`. Deixe o tempo longo o bastante para o ponteiro alcançar o balão. `--tooltip-gap` define o espaço entre o gatilho e o balão da mesma forma. As duas são [variáveis públicas de componente](./customizing.md#variáveis-de-componente).
|
|
80
80
|
|
|
81
81
|
Para o Escape, escreva `data-state="closed"` no `.tooltip`: isso esconde o balão mesmo enquanto ele está com hover ou com foco. Remova o atributo só quando o ponteiro e o foco tiverem saído do tooltip, para que o próximo hover ou foco o abra de novo. Removê-lo antes, enquanto o gatilho ainda tem foco, faz a mensagem reaparecer sem que o usuário faça nada.
|
|
82
82
|
|
package/docs/setup.md
CHANGED
|
@@ -43,9 +43,11 @@ The complete stylesheet includes the reset, the tokens, the layout and type help
|
|
|
43
43
|
|
|
44
44
|
Pick one:
|
|
45
45
|
|
|
46
|
-
- **Compiled CSS** (`@codenhub/styles`, shown above). Use it unless you have a reason not to. Any bundler that resolves CSS imports from packages works, such as Vite, webpack, or the Tailwind CLI.
|
|
46
|
+
- **Compiled CSS** (`@codenhub/styles`, shown above). Use it unless you have a reason not to. Any bundler that resolves CSS imports from packages works, such as Vite, webpack, or the Tailwind CLI. It ships every class, whether your pages use it or not.
|
|
47
47
|
- **Tailwind CSS v4 source** (`@codenhub/styles/tw`). Use it when your project already runs Tailwind v4. Your build compiles the package with your own utilities, so you get one stylesheet and Tailwind's `dark:` variant matches the package's theme. It needs Tailwind 4.3.2 or newer, below 5.
|
|
48
|
-
- **No bundler.** Link the compiled file from `node_modules` or a CDN with a `<link>` tag.
|
|
48
|
+
- **No bundler.** Link the compiled file from `node_modules` or a CDN with a `<link>` tag; see [Without a bundler](./integrating/without-a-bundler.md).
|
|
49
|
+
|
|
50
|
+
To ship only the classes your pages use in a project that does not run Tailwind, with a bundler or without one, the package's `chs build` command reads your files and writes a stylesheet with only those classes, which you import or link in place of the compiled one; see [Build only the classes you use](./integrating/without-a-bundler.md#build-only-the-classes-you-use).
|
|
49
51
|
|
|
50
52
|
Your framework may need its own wiring, such as where the global stylesheet goes in Next.js or Astro. Each of these guides covers one setup and then sends you back here:
|
|
51
53
|
|
|
@@ -70,16 +72,18 @@ The order of the two imports does not matter, because every entrypoint declares
|
|
|
70
72
|
## Requirements
|
|
71
73
|
|
|
72
74
|
- **Browsers:** Chrome 123, Safari 17.5, or Firefox 128 and newer. Colors use `light-dark()` and `color-scheme` (Firefox 120). `.input-group` reads a nested control's invalid and disabled state with `:has()` (Firefox 121). The elevation classes register a non-inheriting property with `@property` (Firefox 128); without it, an elevation class would also reach the unclassed elements inside it.
|
|
73
|
-
- **Tooling:** an `@import` of a package name needs a tool that resolves CSS imports from packages. Without one, link the compiled file by its path or from a CDN; see [Without a bundler](./integrating/without-a-bundler.md).
|
|
74
|
-
- **Tailwind:** 4.3.2 or newer, below 5, only for the `/tw` source entrypoints. It is an optional peer dependency, so the compiled entrypoints do not install it.
|
|
75
|
+
- **Tooling:** an `@import` of a package name needs a tool that resolves CSS imports from packages through their `exports` map. Without one, link the compiled file by its path or from a CDN; see [Without a bundler](./integrating/without-a-bundler.md). Two common tools need a nudge, described in [Integrating → Bundlers that need a nudge](./integrating/index.md#bundlers-that-need-a-nudge): Parcel, and PostCSS with `postcss-import`.
|
|
76
|
+
- **Tailwind:** 4.3.2 or newer, below 5, only for the `/tw` source entrypoints. It is an optional peer dependency, so the compiled entrypoints and the `chs build` command do not install it.
|
|
77
|
+
- **Node.js:** 24 or newer on the machine that runs the `chs build` command. The stylesheets need none, but the package declares it as its engine, so Yarn 1, and npm with `engine-strict`, refuse the install on an older Node.js.
|
|
75
78
|
- **Your application:** the package has no JavaScript. Semantic HTML, ARIA, keyboard behavior, focus management, validation, and announcements are yours; see [Accessibility](./accessibility.md).
|
|
76
79
|
|
|
77
80
|
## When nothing is styled
|
|
78
81
|
|
|
79
82
|
- **The import is missing or not loaded globally.** The classes do nothing until the stylesheet is on the page. Import it once in a stylesheet every page loads, not in a component that may not render.
|
|
80
|
-
- **The package name does not resolve.** A plain `<link>` or a tool without CSS package resolution cannot read `@import "@codenhub/styles"`. Link `node_modules/@codenhub/styles/dist/index.css`, or follow [Without a bundler](./integrating/without-a-bundler.md).
|
|
83
|
+
- **The package name does not resolve.** A plain `<link>` or a tool without CSS package resolution cannot read `@import "@codenhub/styles"`. Link `node_modules/@codenhub/styles/dist/index.css`, or follow [Without a bundler](./integrating/without-a-bundler.md). Parcel and `postcss-import` resolve it with a small change; see [Integrating → Bundlers that need a nudge](./integrating/index.md#bundlers-that-need-a-nudge).
|
|
81
84
|
- **A `/tw` path is loaded without Tailwind.** The `/tw` files are Tailwind source: they contain `@theme`, `@utility`, and `@apply`, which browsers do not understand. Your Tailwind build has to compile them; see [Tailwind CSS v4](./integrating/tailwind.md).
|
|
82
|
-
- **A
|
|
85
|
+
- **A focused `/tw` entrypoint is imported without Tailwind before it.** `@codenhub/styles/tw/button` and the other focused component files do not import Tailwind themselves. Imported alone, they compile without an error but produce no component rules. Put `@import "tailwindcss";` before them; see [Tailwind CSS v4 → Using a focused entrypoint](./integrating/tailwind.md#using-a-focused-entrypoint).
|
|
86
|
+
- **A class built at runtime is missing (Tailwind source only).** Tailwind generates a utility class, the package's components such as `.btn` included, only when it finds the name in your source files. A name assembled from strings, such as `` `btn ${tone}` ``, is invisible to that scan. Write full class names, or list them as described in [Tailwind CSS v4](./integrating/tailwind.md).
|
|
83
87
|
|
|
84
88
|
### Inlining critical CSS
|
|
85
89
|
|
|
@@ -89,9 +93,9 @@ That does not apply to the `/tw` files. They are Tailwind source, not finished C
|
|
|
89
93
|
|
|
90
94
|
## All entrypoints
|
|
91
95
|
|
|
92
|
-
Compiled entrypoints are finished CSS. `/tw` entrypoints publish the uncompiled source from `
|
|
96
|
+
Compiled entrypoints are finished CSS. `/tw` entrypoints publish the uncompiled source from `tw/`, beside `dist/`, which a Tailwind v4 build must process. A focused `/tw` component entrypoint includes the theme tokens, so its classes need nothing else from the package, but it needs `@import "tailwindcss";` before it; see [Tailwind CSS v4 → Using a focused entrypoint](./integrating/tailwind.md#using-a-focused-entrypoint).
|
|
93
97
|
|
|
94
|
-
Each import path resolves the same file under the `style`, `import`, and `default` export conditions. A CSS import is a side effect, so make sure your bundler does not drop it as unused.
|
|
98
|
+
Each import path resolves the same file under the `style`, `import`, and `default` export conditions. A `types` condition comes first and names an empty declaration, so TypeScript accepts a side-effect import such as `import "@codenhub/styles";` with `noUncheckedSideEffectImports`, which TypeScript 6 turns on by default. A CSS import is a side effect, so make sure your bundler does not drop it as unused.
|
|
95
99
|
|
|
96
100
|
| Import path | What it contains and what it changes |
|
|
97
101
|
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -99,7 +103,7 @@ Each import path resolves the same file under the `style`, `import`, and `defaul
|
|
|
99
103
|
| `@codenhub/styles/theme` | Compiled tokens and the intent, presentation, elevation, and corner-pattern classes. Sets root theme properties and the light and dark selectors. No reset and no components. |
|
|
100
104
|
| `@codenhub/styles/palette` | Generated `--palette-*` custom properties: every intent and presentation combination's fill, text, and border color as a flat value, plus flat `border`, `surface`, and `text` colors. For code that cannot use the package itself; see [Customizing → Generated palette](./usage/customizing.md#generated-palette). |
|
|
101
105
|
| `@codenhub/styles/components` | Compiled tokens, typography helpers, and every component class. Each component carries its own reduced-motion rule, and the closed-`<dialog>` fix comes with `.card`. No reset, no layout or content helpers, no classless mappings. |
|
|
102
|
-
| `@codenhub/styles/native` |
|
|
106
|
+
| `@codenhub/styles/native` | Compiled tokens, typography, layout and content helpers, components, and the package reset, plus [classless mappings](#classless-html) for plain HTML elements. Not Tailwind's Preflight. Applies the reset and broad element selectors. |
|
|
103
107
|
| `@codenhub/styles/aesthetics` | All six compiled aesthetics, `.neobrutalism`, `.glass`, `.pixel`, `.chunky-tile`, `.cyber`, and `.sketch`, each with its `-solo` class. No tokens or components of its own; import it in any order. |
|
|
104
108
|
| `@codenhub/styles/aesthetics/*` | One compiled aesthetic and its solo class: `/neobrutalism`, `/glass`, `/pixel`, `/chunky-tile`, `/cyber`, or `/sketch`. |
|
|
105
109
|
| `@codenhub/styles/tw` | Source version of the complete stylesheet. Imports Tailwind itself, then the theme, typography, helpers, components, and reset. Same global rules. |
|
|
@@ -111,9 +115,9 @@ Each import path resolves the same file under the `style`, `import`, and `defaul
|
|
|
111
115
|
| `@codenhub/styles/tw/feedback` | Source theme plus `.alert`, `.badge`, `.skeleton`, and `.progress`, with their animations. |
|
|
112
116
|
| `@codenhub/styles/tw/tooltip` | Source theme plus the tooltip classes. |
|
|
113
117
|
| `@codenhub/styles/tw/reset` | Source theme, typography helpers, and the global reset. Changes the root, body, and elements, and sets selection, motion, focus, scrollbar, and forced-colors rules. |
|
|
114
|
-
| `@codenhub/styles/tw/native` | Source version of `/native`: everything plus the reset and the classless mappings. The broadest global effect.
|
|
118
|
+
| `@codenhub/styles/tw/native` | Source version of `/native`: everything but Tailwind's Preflight, plus the package reset and the classless mappings. The broadest global effect. |
|
|
115
119
|
| `@codenhub/styles/tw/typography` | Source theme plus the typography helpers. Sets the theme selectors; no reset, no classless mappings. |
|
|
116
|
-
| `@codenhub/styles/tw/utilities` | Source theme and typography plus the layout and content helpers.
|
|
120
|
+
| `@codenhub/styles/tw/utilities` | Source theme and typography plus the layout and content helpers. |
|
|
117
121
|
| `@codenhub/styles/tw/aesthetics` | All six aesthetics as source. `/tw/aesthetics/neobrutalism`, `/glass`, `/pixel`, `/chunky-tile`, `/cyber`, and `/sketch` publish one each. Plain CSS with no theme or reset side effects. |
|
|
118
122
|
| `@codenhub/styles/package.json` | The package manifest, as JSON. For tools that read the installed version or export map; it is not a stylesheet. |
|
|
119
123
|
|
|
@@ -121,12 +125,12 @@ Do not import two entrypoints that overlap, such as `@codenhub/styles` and `@cod
|
|
|
121
125
|
|
|
122
126
|
## Classless HTML
|
|
123
127
|
|
|
124
|
-
`@codenhub/styles/native` styles plain HTML elements without any classes, for content you cannot add classes to, such as Markdown output or a CMS body. It
|
|
128
|
+
`@codenhub/styles/native` styles plain HTML elements without any classes, for content you cannot add classes to, such as Markdown output or a CMS body. It holds everything the complete stylesheet does except Tailwind's Preflight, the browser-default reset that `@codenhub/styles` brings with Tailwind. The package's own reset is in it: box sizing, the root background, text color and font, the margin reset on headings, paragraphs, and lists, selection colors, focus rings, and the reduced-motion rule. Then it adds these mappings:
|
|
125
129
|
|
|
126
130
|
| Element | Styled as |
|
|
127
131
|
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
128
132
|
| `h1`, `h2`, `h3`, `h4`, `h5` and `h6` | `.text-title-lg`, `.text-title`, `.text-title-sm`, `.text-label-lg`, `.text-label` |
|
|
129
|
-
| `
|
|
133
|
+
| `body` | `.text-body`, inherited by paragraphs, list items, and other text |
|
|
130
134
|
| `table` | `.data-table` |
|
|
131
135
|
| `kbd`, `blockquote`, `q`, `code`, `pre` | `.kbd`, `.quote`, `.quote-inline`, `.code`, `.pre` |
|
|
132
136
|
| `hr` | `.divider` |
|
|
@@ -134,6 +138,8 @@ Do not import two entrypoints that overlap, such as `@codenhub/styles` and `@cod
|
|
|
134
138
|
| `textarea`, `select` | `.textarea`, `.select` |
|
|
135
139
|
| `input type="checkbox"`, `input type="radio"` | `.checkbox`, `.radio` |
|
|
136
140
|
| `button`, `input type="button"`, `type="submit"`, `type="reset"` | `.btn` |
|
|
141
|
+
| `dialog` | `.card.floating`: hidden until opened, then a centered floating card |
|
|
142
|
+
| `progress` | `.progress`, filled to its `value`; with no `value` it is the indeterminate sweep |
|
|
137
143
|
|
|
138
144
|
```html
|
|
139
145
|
<article>
|
|
@@ -151,7 +157,9 @@ What it does not do:
|
|
|
151
157
|
- **Some input types are left alone:** `file`, `range`, `color`, and `hidden` keep the browser's own look.
|
|
152
158
|
- **No switch.** A checkbox with `role="switch"` is still painted as a checkbox; the mapping does not read roles. A page that needs switches is better served by the class-based stylesheet.
|
|
153
159
|
- **Links keep the text around them.** A link inside a heading stays heading-sized; a link is never styled as a button.
|
|
154
|
-
-
|
|
160
|
+
- **Body text is set once.** `p` and `li` take their type from the element they sit in, so a container that sets its own size, weight, or tracking applies it to the Markdown inside it. Controls keep their own tracking: a button, a badge, and a text field print `normal`, whatever the page or the container sets.
|
|
161
|
+
- **Native behavior stays native.** A `<dialog>` opens with `show()` or `showModal()` as usual; the mapping only paints it. A `<progress>` sweep stops under a reduced-motion preference, and in forced colors the bar uses the system colors.
|
|
162
|
+
- **`pre code` is not double-styled.** Code inside a `pre` drops the chip it would draw on its own: background, padding, border, shadow, glow, and clip.
|
|
155
163
|
|
|
156
164
|
The mappings are global: every matching element on the page is styled, including elements inside third-party widgets. They sit in the `base` [cascade layer](#cascade-layers), so any class beats them. Add an intent or presentation class to a mapped element, such as `<button class="destructive">`, and it applies as it would on `.btn`.
|
|
157
165
|
|
|
@@ -159,18 +167,19 @@ The mappings are global: every matching element on the page is styled, including
|
|
|
159
167
|
|
|
160
168
|
Every entrypoint puts its CSS into Tailwind's four cascade layers and declares their order before using one, so the result does not depend on which file loads first:
|
|
161
169
|
|
|
162
|
-
| Layer | Holds
|
|
163
|
-
| ------------ |
|
|
164
|
-
| `theme` | Tailwind's theme, the foundation tokens, the theme selectors, and `/palette`.
|
|
165
|
-
| `base` | The reset and the classless element styles.
|
|
166
|
-
| `components` | The intent
|
|
167
|
-
| `utilities` | Every component (`.btn`, `.card`, `.ipt`, and so on), next to your own Tailwind utilities.
|
|
168
|
-
| _unlayered_ | The forced-colors and reduced-motion overrides, the closed-`<dialog>` fix, and the `-solo` classes.
|
|
170
|
+
| Layer | Holds |
|
|
171
|
+
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
172
|
+
| `theme` | Tailwind's theme, the foundation tokens, the theme selectors, and `/palette`. |
|
|
173
|
+
| `base` | The reset and the classless element styles. |
|
|
174
|
+
| `components` | The aesthetic classes and the neutral intent values every component starts from. |
|
|
175
|
+
| `utilities` | Every component (`.btn`, `.card`, `.ipt`, and so on), next to your own Tailwind utilities. The intent, presentation, edge, elevation, corner, and size classes sit in `utilities.families`, a sublayer that loses to every other rule in `utilities`. |
|
|
176
|
+
| _unlayered_ | The forced-colors and reduced-motion overrides, the closed-`<dialog>` fix, and the `-solo` classes. |
|
|
169
177
|
|
|
170
178
|
What that means when you write your own CSS:
|
|
171
179
|
|
|
172
|
-
- **Your utility or unlayered CSS beats an intent, presentation, elevation, or aesthetic class** on the same element. `[--ui-fill:50%]` on a `.solid` button, `font-serif` on a `.pixel` region, or `.my-card { --ui-radius: 0 }` in your own stylesheet all apply.
|
|
180
|
+
- **Your utility or unlayered CSS beats an intent, presentation, elevation, or aesthetic class** on the same element. `[--ui-fill:50%]` on a `.solid` button, `font-serif` on a `.pixel` region, or `.my-card { --ui-radius-surface: 0 }` in your own stylesheet all apply.
|
|
173
181
|
- **A component and your utility share the `utilities` layer.** Specificity decides between them, then source order, as between any two utilities. Your unlayered CSS always beats a component.
|
|
182
|
+
- **Your utility beats a component's inner defaults.** `p-0 text-center` on a table cell, `text-sm` on a `.label`, or `px-8` on a `.btn.sm` applies, because the component writes those defaults so that a class on the element wins.
|
|
174
183
|
- **State beats your intent.** A field with `aria-invalid="true"` stays destructive even with an intent utility on it.
|
|
175
184
|
- **The `-solo` classes are unlayered on purpose**, so they beat a third-party component's layered or zero-specificity styles. A more specific unlayered rule, or an equally specific one that loads later, still beats them; see [Solo classes](./usage/solo.md).
|
|
176
185
|
|
package/docs/usage/aesthetics.md
CHANGED
|
@@ -70,8 +70,10 @@ The shadow is cast in the component's own intent, so a success button throws a g
|
|
|
70
70
|
|
|
71
71
|
- Content chips take the aesthetic too. A `.kbd` key cap's border changes from the quiet border gray to the ink, and from 1px to 2px, like every other border. A `.code` or `.pre` has no border by default, so it gets none; add `.edged` to give one an ink border.
|
|
72
72
|
- Only `.btn` and an opted-in `.card` respond to hover and press. A card opts in with `.interactive`, or with one of its halves — `.hoverable` for the hover response alone, `.pressable` for the press alone; a plain card, an alert, or a panel is a container and stays put.
|
|
73
|
-
- An alert sits on the offset shadow under this aesthetic, and under no other. An alert is otherwise flat, but here the shadow is a second outline rather than depth, and an alert without it looks unfinished next to everything else. This includes an alert inside a nested `.neobrutalism` region. `.flat` still removes it and `.floating` still doubles it.
|
|
73
|
+
- An alert sits on the offset shadow under this aesthetic, and under no other. An alert is otherwise flat, but here the shadow is a second outline rather than depth, and an alert without it looks unfinished next to everything else. This includes an alert inside a nested `.neobrutalism` region, and an alert that carries the class itself, `.alert.neobrutalism`. `.flat` still removes it and `.floating` still doubles it.
|
|
74
74
|
- The tooltip trigger takes the zero corner like everything else and draws square; `.radio` keeps its circle.
|
|
75
|
+
- Under `prefers-reduced-motion: reduce` the press still happens, but at once: the element lands in its shadow without travelling there. The press is the feedback that a click registered, so only its motion goes.
|
|
76
|
+
- It has no font of its own and sets the theme's, `--font-default`, on the region, so a neobrutalist region nested inside pixel, cyber, sketch, or chunky tile does not take their face. A font you set with `font-family` alone, on `body` or a container, does not reach inside the region; set it in `--font-default` too, as [Theming → Fonts](./theming.md#fonts) describes.
|
|
75
77
|
|
|
76
78
|
## Glass
|
|
77
79
|
|
|
@@ -90,8 +92,9 @@ The shadow is cast in the component's own intent, so a success button throws a g
|
|
|
90
92
|
- Every surface in a glass region is glass, a neutral `.card.soft`, `.panel`, and `.alert` included.
|
|
91
93
|
- The glass is the ground, not the fill. A presentation keeps its whole fill, so a `.solid` button, a checked toggle, and a `.solid` card or table are opaque; the default, `.soft`, and `.ghost` panes are the frosted ones.
|
|
92
94
|
- The blur applies to `.card`, `.panel`, `.alert`, the tooltip bubble, and a default or `.soft` `.data-table` only. Controls stay solid and sit on the glass: a blur under every control of a dense cluster costs a composited layer apiece and reads as noise. Controls still take the aesthetic's radius, border, and shadow.
|
|
93
|
-
- Under `prefers-reduced-transparency: reduce`, glass surfaces drop the blur and become opaque.
|
|
94
|
-
- Buttons and an opted-in `.card` press with the plain `scale(0.97)`; reduced motion
|
|
95
|
+
- Under `prefers-reduced-transparency: reduce`, and in forced colors, glass surfaces drop the blur and become opaque. Forced colors replace the colors but keep their transparency, so without this a pane would show the page through the system's background.
|
|
96
|
+
- Buttons and an opted-in `.card` press with the plain `scale(0.97)`; under reduced motion the press still happens, at once.
|
|
97
|
+
- It has no font of its own and sets the theme's, `--font-default`, on the region, as neobrutalism does.
|
|
95
98
|
- Text controls and toggles draw their line in the page's ink at 55% rather than the white hairline, which would erase an unchecked checkbox on a light page. It is `--ui-control-ink`; set it on the region to choose another.
|
|
96
99
|
- A table's frame and rules draw the page's ink at 20%, because the hairline vanishes on the table's plate. It is `--ui-rule-ink`.
|
|
97
100
|
- A table with a `<caption>` blurs behind the caption as well as its rows in Chromium and Safari, whose table box includes the caption, and under `.glass-liquid` the rim and sheen frame the caption too. Firefox keeps the caption off the pane. Label the table from a heading outside it with `aria-labelledby` where that matters.
|
|
@@ -110,13 +113,13 @@ The lens is drawn by an SVG filter in `backdrop-filter`, which Chromium renders
|
|
|
110
113
|
|
|
111
114
|
**Exceptions:**
|
|
112
115
|
|
|
113
|
-
- It reaches `.card`, `.panel`, `.alert`, the tooltip bubble, and a default or `.soft` `.data-table`. Controls stay solid, as they do under glass, except a button that asks: see [Liquid buttons](#liquid-buttons).
|
|
116
|
+
- It reaches `.card`, `.panel`, `.alert`, `.surface`, the tooltip bubble, a component of your own built with `@apply surface`, and a default or `.soft` `.data-table`. Controls stay solid, as they do under glass, except a button that asks: see [Liquid buttons](#liquid-buttons).
|
|
114
117
|
- It draws its blur and lens on each surface's `::before` and `::after`, so a surface inside a liquid region cannot carry a `::before` or `::after` of your own. Each surface also becomes a positioned stacking context; a surface you position yourself keeps your placement.
|
|
115
|
-
- Anything else that frosts under glass keeps liquid's light blur and its clearer ground, without the lens or the rim: a bare `<table>` under `/native
|
|
118
|
+
- Anything else that frosts under glass keeps liquid's light blur and its clearer ground, without the lens or the rim: a bare `<table>` under `/native`.
|
|
116
119
|
- The lens is 8px of erosion blurred over 10px on every surface, and 3px blurred over 3.5px on a button; its strength is fixed. A filter cannot read a custom property, so neither is a knob. The corners are, through `--glass-radius` and `--glass-radius-surface`, with larger defaults: a continuous corner reads smaller than a round one of the same radius.
|
|
117
|
-
- A region of another aesthetic nested inside a liquid region, or of plain `.glass`, keeps its own material and takes no layers.
|
|
120
|
+
- The nearest region decides. A region of another aesthetic nested inside a liquid region, or of plain `.glass`, keeps its own material and takes no layers, and a liquid region nested again inside that takes them back.
|
|
118
121
|
- Without `.glass` in scope it changes the corners and nothing else.
|
|
119
|
-
- Under `prefers-reduced-transparency: reduce
|
|
122
|
+
- Under `prefers-reduced-transparency: reduce`, and in forced colors, the blur and the lens go and the surface is opaque, as under glass.
|
|
120
123
|
- Text sits over a clearer pane than under glass. Over busy content, check that your text still reads: the ground is 30% of the page color, where glass's is 45%.
|
|
121
124
|
|
|
122
125
|
#### Liquid buttons
|
|
@@ -151,8 +154,9 @@ A button is a liquid pane when it carries `.glass-liquid` itself, inside a glass
|
|
|
151
154
|
**Exceptions:**
|
|
152
155
|
|
|
153
156
|
- Corners are one unit or nothing. Small chips are square instead of stepped: badges, key caps, inline code, checkboxes, and switches. One unit off each corner of a 24px badge would look like a bite, not a corner.
|
|
157
|
+
- Surfaces are square too: a `.card`, `.panel`, or `.alert` keeps the inset ring but takes no cut and clips nothing. A clip would cut everything inside it, so a tooltip in a card, a shadow, or a focus ring there would be trimmed.
|
|
154
158
|
- Tables, progress bars, and skeletons are square too. A table takes no cut because in Chromium and WebKit its box includes its caption, and the cut would land on the caption instead of the rows. Progress bars and skeletons take only the square corner.
|
|
155
|
-
- A `.pre` code block is stepped like a
|
|
159
|
+
- A `.pre` code block is stepped like a button. It has no border by default, so the cut shows with no outline around it.
|
|
156
160
|
- The outline is an inset ring, because a clip removes a real border — and the focus ring, for the same reason, is a second inset layer rather than an outline. Both are the element's own edge rather than a shadow, so the border answers `.edged` and `.edgeless` the way a border does: a `.edgeless` badge and a `.solid` button draw none, a `.edged` card draws one, and a field keeps one whatever a container asks for.
|
|
157
161
|
- The inset focus ring carries a 2px line of the page color inside it. The ring is the primary color, so on a `.solid.primary` button it would be drawn over its own color; the line is what shows there.
|
|
158
162
|
- In forced colors the ring and the cut both go, because the system removes every box shadow: components draw a real 2px border and square corners, and `.pixel-solo` an inward outline.
|
|
@@ -176,7 +180,7 @@ The bar is a darker shade of the element's own color rather than a shadow under
|
|
|
176
180
|
|
|
177
181
|
**Exceptions:**
|
|
178
182
|
|
|
179
|
-
- Only
|
|
183
|
+
- Only buttons and cards sit on a bar, because they are the components resting above zero elevation. A badge, chip, field, or tooltip is flat until it asks for depth with `.raised`, and `.flat` takes the bar off anything:
|
|
180
184
|
|
|
181
185
|
```html
|
|
182
186
|
<div class="card soft edgeless info flat">Promo panel, deliberately flat</div>
|
|
@@ -186,7 +190,8 @@ The bar is a darker shade of the element's own color rather than a shadow under
|
|
|
186
190
|
- Labels are drawn heavier and slightly tracked, through `--ui-label-weight` and `--ui-label-tracking`, so your own `font-*` or `tracking-*` utility still wins. It reaches `.btn` and `.badge`, and a bare `<button>` only where `/native` styles it. Casing is left alone: how a label is worded is the application's decision, so if you want uppercase buttons, write that rule in your own stylesheet.
|
|
187
191
|
- `.card.interactive` presses like a `.btn`, so a chunky answer tile drops onto its bar on click; `.card.pressable` gets the same press on its own. A plain `.card` stays put.
|
|
188
192
|
- The shipped `.primary` is near-black on a light page and near-white on a dark one, and the bar is always mixed toward black. On a light page, a primary button's bar is almost invisible against its near-black face (measured `1.04:1`). On a dark page, the near-white face against the same bar reads well (`2.48:1`). Give `.primary` a hue of its own if it is the call to action and needs the depth cue in both themes.
|
|
189
|
-
-
|
|
193
|
+
- Under `prefers-reduced-motion: reduce` the press still happens, but at once, as under neobrutalism.
|
|
194
|
+
- Depth in this aesthetic is the bar, never a blurred drop shadow. Anything that rests flat sits flush on the page.
|
|
190
195
|
- Controls draw a heavier gray than the tiles around them, `neutral-600` in light and `neutral-400` in dark, through `--ui-control-ink`, so a field reads as a field inside a tile.
|
|
191
196
|
|
|
192
197
|
## Cyber
|
|
@@ -236,7 +241,7 @@ Hand-drawn outlines: controls take long, uneven elliptical corners, and cards, p
|
|
|
236
241
|
|
|
237
242
|
The 1px ink line is solid; checkboxes, dividers, and table rules are dashed. `--ui-line-style: dashed` dashes any other component, and `--ui-rule-style: solid` puts a divider or table back to solid. The 2px hard shadow is a small neutral depth cue.
|
|
238
243
|
|
|
239
|
-
`--sketch-radius`, `--sketch-radius-surface`, and `--sketch-radius-pill` replace the control, surface, and pill-button outlines. Set one and every position takes that one outline. To shape a single component instead, set `--ui-radius` (`--ui-radius-surface` on a surface) on it.
|
|
244
|
+
`--sketch-radius`, `--sketch-radius-surface`, and `--sketch-radius-pill` replace the control, surface, and pill-button outlines. Set one on the region or on any element inside it, and every position below takes that one outline, on the components that rotate: `.btn`, `.ipt`, `.textarea`, `.select`, `.input-group`, `.pre`, and `.tooltip-bubble` for the control outline, and `.card`, `.panel`, `.alert`, and `.data-table` for the surface one. Any other element that takes a control or surface outline, such as a `.skeleton` or a bare control under `/native`, takes the outline the region itself resolved, so a knob set between the region and that element does not reach it; set the knob on the region instead. Chips, such as `.badge` and `.checkbox`, take small outlines of their own that no knob changes. To shape a single component instead, set `--ui-radius` (`--ui-radius-surface` on a surface) on it.
|
|
240
245
|
|
|
241
246
|
```html
|
|
242
247
|
<section class="sketch" style='--font-sketch: "Comic Sans MS", cursive'>
|
|
@@ -259,11 +264,12 @@ The dashed button is `ghost edged` because a filled button has no separate line
|
|
|
259
264
|
|
|
260
265
|
**Exceptions:**
|
|
261
266
|
|
|
262
|
-
- Sketch names components to rotate their outlines, so its outlines reach only this package's components; a region of another aesthetic nested inside a sketch region keeps that aesthetic's corners.
|
|
267
|
+
- Sketch names components to rotate their outlines, so its outlines reach only this package's components; a region of another aesthetic nested inside a sketch region keeps that aesthetic's corners. The nearest region decides, so a sketch region nested again inside that one rotates.
|
|
263
268
|
- Chips, such as checkboxes, key caps, code, badges, switches, and progress bars, rotate through small uneven outlines set in `--ui-radius-tight`. Set that token on a chip to choose its shape.
|
|
264
269
|
- A `.btn.pill` takes a rounded pill bounded to its own height, so a wide one does not become an oval. Badges, progress bars, and switches take their chip outline. Radios and the tooltip icon stay circles, slightly uneven, so a radio is never mistaken for a checkbox. An explicit `--ui-radius-pill` on an element still wins.
|
|
265
270
|
- `--font-sketch` is yours to supply. The package ships no handwriting font and falls back to the platform `cursive` family.
|
|
266
|
-
- Buttons press with the plain `scale(0.97)`; reduced motion
|
|
271
|
+
- Buttons press with the plain `scale(0.97)`; under reduced motion the press still happens, at once.
|
|
272
|
+
- With [`/native`](../setup.md#classless-html), a plain `<hr>`, `<table>`, and checkbox take the dashed accents of `.divider`, `.data-table`, and `.checkbox`.
|
|
267
273
|
- Forced-colors mode draws the dashed accents solid, like every other material line.
|
|
268
274
|
|
|
269
275
|
## Solo classes
|
package/docs/usage/buttons.md
CHANGED
|
@@ -39,7 +39,11 @@ A button accepts one intent, one fill class, and one edge class, all optional. W
|
|
|
39
39
|
|
|
40
40
|
A **neutral** button never fills completely. Its color is the page's own text color, so a full fill would be a black or white block, the loudest thing on the page for the intent that means nothing in particular. A neutral `.solid` button stops at a 20% fill instead, a quiet gray a step darker than `.soft`. Every named intent fills to 100%.
|
|
41
41
|
|
|
42
|
-
On hover, a button's fill deepens by `--hover-step` (14%), so a `.ghost` button picks up a tint and a `.solid` one changes to its intent's hover color. On press it scales down slightly (`scale(0.97)`); an [aesthetic](./aesthetics.md) can replace that with its own press, and a user's reduced-motion preference
|
|
42
|
+
On hover, a button's fill deepens by `--hover-step` (14%), so a `.ghost` button picks up a tint and a `.solid` one changes to its intent's hover color. On press it scales down slightly (`scale(0.97)`); an [aesthetic](./aesthetics.md) can replace that with its own press, and under a user's reduced-motion preference it still happens, at once.
|
|
43
|
+
|
|
44
|
+
A neutral `.soft` or `.ghost` button inside a filled surface, such as a Cancel button in a `.card.solid.primary` or an `.alert.solid.destructive`, prints its label and its line in that surface's text color, so it stays readable on the fill. A text field does the same. A button with an intent keeps its own color, and so does a neutral `.solid` one, which rests on a fill of its own.
|
|
45
|
+
|
|
46
|
+
When a filled button has keyboard focus, a 2px line of the page color runs inside the focus ring, so the ring stays visible on a button filled with the same color, such as `.solid.primary`.
|
|
43
47
|
|
|
44
48
|
## Sizes and shapes
|
|
45
49
|
|
package/docs/usage/composing.md
CHANGED
|
@@ -22,6 +22,9 @@ This is a lookup page. [Building a screen](../concepts.md) introduces intent, pr
|
|
|
22
22
|
- **Aesthetics and [material tokens](./customizing.md#material-tokens) pass down** the same way.
|
|
23
23
|
- **Intent does not pass down.** `.primary` and the other intent classes color only the element they are on. A container that silently recolored everything inside it would turn a red danger-zone card's neutral Cancel button red. `.neutral` names the default; use it where an element would otherwise take an intent, such as a table row inside a `.success` table. See [Theming → Intent tokens](./theming.md#intent-tokens).
|
|
24
24
|
- **Elevation does not pass down.** `.raised` lifts only the element it is on; see [Elevation](#elevation).
|
|
25
|
+
- **Size does not pass down.** `.sm` and `.lg` resize only the button or control they are on, so a `.sm` form does not shrink the fields inside it. See [Buttons → Sizes and shapes](./buttons.md#sizes-and-shapes) and [Forms → Sizes](./forms.md#sizes).
|
|
26
|
+
|
|
27
|
+
With the Tailwind source entrypoints, every class above except the aesthetic classes is also a Tailwind utility, so variants such as `md:lg` and `dark:solid` work and `@apply btn primary soft sm` gives one class of yours the whole combination. The modifiers documented with each component, such as `.tight` or `.interactive`, are utilities too, so `@apply stack tight` works. The aesthetic classes, such as `.glass`, stay plain CSS, so `@apply glass` and `md:glass` do not work; write the class in the markup. See [Tailwind CSS v4 → Build your own components with `@apply`](../integrating/tailwind.md#build-your-own-components-with-apply), and [Presets](./presets.md) for when to reach for it.
|
|
25
28
|
|
|
26
29
|
## Component defaults
|
|
27
30
|
|
|
@@ -77,6 +80,7 @@ A neutral `.card.soft`, `.panel`, and `.alert` show no tint at rest. They use th
|
|
|
77
80
|
|
|
78
81
|
- A `.card.soft` with `.interactive` or `.hoverable` shows the tint on hover. A plain `.card.soft` and a `.panel` have no hover state.
|
|
79
82
|
- With one of the six built-in intents, all three keep the ordinary 12% tint, and a card deepens it on hover. An intent you defined yourself is treated as neutral here; see [Theming → Your own intent](./theming.md#your-own-intent).
|
|
83
|
+
- The presentation can come from the element or from a container: `<div class="soft"><div class="card">` rests like `.card.soft`, and a `.ghost` or `.solid` container gives a `.panel` or `.alert` the plate its own class would.
|
|
80
84
|
- A `.badge` keeps its 12% tint even when neutral. It has no border, so without the tint it would disappear into the text around it.
|
|
81
85
|
|
|
82
86
|
`.kbd`, `.code`, and `.pre` work differently. They rest on their intent's subtle tone, `--intent-subtle`, which is `--color-surface` for neutral, and a built-in intent adds 12% of its color over it. An intent you defined yourself shows its own `--intent-subtle` tint without that extra 12%.
|
|
@@ -138,7 +142,7 @@ Which classes change each component. "Material" is what an [aesthetic](./aesthet
|
|
|
138
142
|
| `.progress` | Track fill, border, and border width. The filled part is always the full intent color. |
|
|
139
143
|
| `.skeleton`, `.divider` | Intent only. |
|
|
140
144
|
|
|
141
|
-
State and modifier classes such as `.interactive`, `.hoverable`, `.pressable`, `.p-sm`, and `.vertical` are documented with their component. An invalid control is marked with `aria-invalid="true"`, not a class; see [Forms](./forms.md#show-a-validation-error).
|
|
145
|
+
State and modifier classes such as `.interactive`, `.hoverable`, `.pressable`, `.p-sm`, and `.vertical` are documented with their component. Each takes effect on the components that read it, and on `/tw` they are utilities, so `@apply card interactive` works. An invalid control is marked with `aria-invalid="true"`, not a class; see [Forms](./forms.md#show-a-validation-error).
|
|
142
146
|
|
|
143
147
|
## Elevation
|
|
144
148
|
|