Toolbar
Группа элементов управления с одной остановкой табуляции и навигацией стрелками.
- Браузеры
- Chrome 123+Firefox 121+Safari 17.5+
- Уровень
- 1
- Сжатый размер
- 2.04 kB
- Лимит принудительной компоновки
- 0 ms
- Лимит axe
- 0
- Совместим с SSR
- Да
- Публичный контракт
- Тестовый стенд
Песочница
Toolbar
По умолчанию
import { Toolbar } from "@gunkin/uiify";
export default function Example() {
return (
<Toolbar.Root className="" aria-label="Formatting">
<Toolbar.Button>Bold</Toolbar.Button>
<Toolbar.Separator className="" />
<Toolbar.Button>Italic</Toolbar.Button>
</Toolbar.Root>
);
}/* Toolbar — grouped action buttons with separators. */
@layer components {
[data-uiify-toolbar][data-part="root"] {
display: inline-flex;
align-items: center;
gap: var(--space-xs);
padding: var(--space-xs);
border: var(--border-width) solid var(--border);
border-radius: var(--radius-full);
corner-shape: round;
background-color: var(--card);
}
[data-uiify-toolbar][data-part="root"] > hr[data-part="separator"][data-orientation] {
flex: none;
align-self: stretch;
inline-size: var(--border-width);
block-size: auto;
margin-inline: var(--space-md);
border: 0;
background-color: var(--border);
}
}import { Toolbar } from "@gunkin/uiify";
export default function Example() {
return (
<Toolbar.Root
className="
data-[part=root]:inline-flex data-[part=root]:items-center data-[part=root]:gap-xs data-[part=root]:p-xs
data-[part=root]:border-[length:var(--border-width)] data-[part=root]:border-solid
data-[part=root]:border-border data-[part=root]:rounded-[var(--radius-full)]
data-[part=root]:[corner-shape:round] data-[part=root]:bg-card
[&[data-part=root]>hr[data-part=separator][data-orientation]]:flex-none
[&[data-part=root]>hr[data-part=separator][data-orientation]]:self-stretch
[&[data-part=root]>hr[data-part=separator][data-orientation]]:[inline-size:var(--border-width)]
[&[data-part=root]>hr[data-part=separator][data-orientation]]:[block-size:auto]
[&[data-part=root]>hr[data-part=separator][data-orientation]]:mx-md
[&[data-part=root]>hr[data-part=separator][data-orientation]]:border-0
[&[data-part=root]>hr[data-part=separator][data-orientation]]:border-current
[&[data-part=root]>hr[data-part=separator][data-orientation]]:border-none
[&[data-part=root]>hr[data-part=separator][data-orientation]]:bg-border
"
aria-label="Formatting"
>
<Toolbar.Button>Bold</Toolbar.Button>
<Toolbar.Separator className="" />
<Toolbar.Button>Italic</Toolbar.Button>
</Toolbar.Root>
);
}/* app.css */
@layer reset, ui, app, tokens, base, demo, components, utilities, theme;
@import "@gunkin/uiify/styles/reset";
@import "@gunkin/uiify/components/behavior.css";
@import "@gunkin/uiify/styles/tokens";
@import "@gunkin/uiify/styles/tailwind";
@import "tailwindcss/utilities.css";
@theme { --spacing: 0.25rem; --font-weight-normal: 400; --font-weight-medium: 500; --font-weight-semibold: 600; --font-weight-bold: 700; }
@source inline('data-[part=root]:inline-flex data-[part=root]:items-center data-[part=root]:gap-xs data-[part=root]:p-xs data-[part=root]:border-[length:var(--border-width)] data-[part=root]:border-solid data-[part=root]:border-border data-[part=root]:rounded-[var(--radius-full)] data-[part=root]:[corner-shape:round] data-[part=root]:bg-card [&[data-part=root]>hr[data-part=separator][data-orientation]]:flex-none [&[data-part=root]>hr[data-part=separator][data-orientation]]:self-stretch [&[data-part=root]>hr[data-part=separator][data-orientation]]:[inline-size:var(--border-width)] [&[data-part=root]>hr[data-part=separator][data-orientation]]:[block-size:auto] [&[data-part=root]>hr[data-part=separator][data-orientation]]:mx-md [&[data-part=root]>hr[data-part=separator][data-orientation]]:border-0 [&[data-part=root]>hr[data-part=separator][data-orientation]]:border-current [&[data-part=root]>hr[data-part=separator][data-orientation]]:border-none [&[data-part=root]>hr[data-part=separator][data-orientation]]:bg-border');
@layer base { :root { --uiify-control-text: var(--text-sm); } @media (pointer: coarse) { :root { --uiify-control-text: var(--text-base); } } }
/* Authored animation and registered properties used by the Tailwind skin.
* Visual rules belong in utility recipes; only at-rule definitions live here. */
@layer components {
@keyframes uiify-presence-in {
from {
opacity: 0;
scale: var(--presence-scale);
}
}
}
@layer components {
@keyframes uiify-presence-out {
to {
opacity: 0;
scale: var(--presence-scale);
}
}
}
@property --uiify-spinner-tail {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
@property --uiify-spinner-length {
syntax: "<angle>";
inherits: false;
initial-value: 36deg;
}
@layer components {
@keyframes uiify-spinner-rotate {
to {
transform: rotate(360deg);
}
}
}
@layer components {
@keyframes uiify-spinner-orbit {
0% {
--uiify-spinner-tail: 0deg;
--uiify-spinner-length: 36deg;
}
50% {
--uiify-spinner-tail: 90deg;
--uiify-spinner-length: 324deg;
}
100% {
--uiify-spinner-tail: 360deg;
--uiify-spinner-length: 36deg;
}
}
}
@layer components {
@keyframes uiify-skeleton-pulse {
50% {
opacity: 0.45;
}
}
}
@layer components {
@keyframes uiify-skeleton-shimmer {
to {
background-position: -200% 0;
}
}
}
@layer components {
@keyframes uiify-skeleton-reveal {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
}
@property --candle-body-height {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-body-top {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --candle-slot {
syntax: "<percentage>";
inherits: true;
initial-value: 100%;
}
@property --candle-wick-height {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-wick-top {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --candle-x {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-scale {
syntax: "<number>";
inherits: true;
initial-value: 1;
}
@property --line-y {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --line-prev-y {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --line-count {
syntax: "<integer>";
inherits: false;
initial-value: 1;
}
@property --line-scale {
syntax: "<number>";
inherits: true;
initial-value: 1;
}
@layer components {
@keyframes uiify-otp-input-caret-blink {
50% {
opacity: 0;
}
}
}API
Toolbar.Root
| Свойство | Тип | По умолчанию | Описание |
|---|---|---|---|
dir | "ltr" | "rtl" | — | Направление письма, меняющее местами действия стрелок влево и вправо. |
loop | boolean | true | Переходит ли навигация стрелками по кругу между первым и последним пунктами. |
orientation | "horizontal" | "vertical" | "both" | "horizontal" | Стрелки, перемещающие фокус между пунктами, и значение data-orientation. |
Toolbar.Button
| Свойство | Тип | По умолчанию | Описание |
|---|---|---|---|
selected | boolean | — | Состояние переключения кнопки: задаёт aria-pressed, а при true — data-selected и основную заливку. |
children | ReactNode | — | Содержимое кнопки. |
className | string | — | Класс элемента кнопки. |
disabled | boolean | false | Отключает кнопку и исключает её из порядка перемещения фокуса внутри группы. |
Toolbar.Link
| Свойство | Тип | По умолчанию | Описание |
|---|---|---|---|
children | ReactNode | — | Содержимое ссылки. |
className | string | — | Класс элемента ссылки. |
href* | string | — | Адрес ссылки, переход по которой работает без JavaScript. |
Toolbar.Separator
| Свойство | Тип | По умолчанию | Описание |
|---|---|---|---|
className | string | — | Класс элемента <hr>. |
orientation | "horizontal" | "vertical" | "vertical" | Задаёт разделителю aria-orientation и data-orientation. |
Toolbar.ToggleGroup
| Свойство | Тип | По умолчанию | Описание |
|---|---|---|---|
id* | string | — | Основа детерминированных идентификаторов и общего имени группы полей. |
type | "single" | "multiple" | "single" | Разрешено ли нажать один или несколько переключателей; определяет выбор полей radio или checkbox. |
items* | readonly ToggleGroupItem[] | — | Каждый пункт имеет вид { value, label, disabled? }. |
defaultValue | string | readonly string[] | undefined | — | Нажатое состояние при первом рендеринге. Неуправляемое, поэтому сохраняется без JavaScript. |
orientation | "horizontal" | "vertical" | "horizontal" | Направление расположения переключателей. |
className | string | — | Класс корня группы. |
Клавиатура
| Клавиша | Действие |
|---|---|
| Tab | Перевести фокус на элемент управления или с него |
| Enter / Space | Активировать при наличии фокуса (для элементов управления типа кнопки) |
Доступность
По возможности используется семантический HTML. Изучите разметку в песочнице: ARIA добавляется только там, где нативных элементов недостаточно.
Привязка стилей
data-disabled