Toggle Group
Weekday Filter
A multi-select weekday filter: seven round toggles, a live summary line and a separate "Weekdays only" action button.
- togglegroup
- weekdays
- filter
- multiple
Preview
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this in the header: https://vibeui.ru/c/togglegroup-004?lang=en
Delivery days
3 дня: Пн, Ср, Пт.
The courier comes only on the selected days.
Show the full instructions
What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.
# Install and place "togglegroup-004" (Weekday Filter) from VibeUI
## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/togglegroup-004.json
Registry item: https://vibeui.ru/r/togglegroup-004.json
Installs to: components/vibeui/togglegroup-004.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.
Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.
## 2. What it is
A multi-select weekday filter: seven round toggles, a live summary line and a separate "Weekdays only" action button.
Multi-select weekday picking with round toggles, a live summary and a quick weekdays preset. One file, zero dependencies, client component.
## 3. How to use it
import { Togglegroup004 } from "@/components/vibeui/togglegroup-004"
<Togglegroup004
label="Delivery days"
hint="The courier comes only on the selected days."
defaultValue={["mon", "wed", "fri"]}
/>
Read the installed file for the full prop list.
## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.
Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)
## 5. Keep exactly as installed
- the local --vibeui-togglegroup-004-* palette — do not swap it for your theme tokens
- full day names in aria-label: "Mo" does not decode by ear
- aria-pressed on the circles — this is selection state, not an action trigger
- the different look of the toggles and the "Weekdays only" button: an action must not look like a state
- the summary line with a count and a list — seven circles are not read at a glance
- the panel's own light surface: dark text must bring its own background
## 6. You may change
- the group name through label
- the note under the group through hint
- the initial set of days through defaultValue
- the colour of selected weekdays through accent
## 7. Rules
- An empty selection is allowed and stated honestly: if it is invalid, validate outside.
- Day ids are latin (mon…sun) while captions are localised: do not mix them up.
- The "Weekdays only" button overwrites the whole selection rather than adding to it.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.
## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.For developers
npx shadcn@latest add https://vibeui.ru/r/togglegroup-004.jsonhttps://vibeui.ru/r/togglegroup-004.jsonОдин файл, ноль зависимостей, палитра --vibeui-togglegroup-004-*. Клиентский: useState с массивом идентификаторов. Кружок — это toggle: нажат или нет, третьего не дано, поэтому у каждого aria-pressed и полное имя дня в aria-label (две буквы «Пн» без расшифровки звучат плохо). Рядом стоит «Только будни» — это не тумблер, а действие над выбором, и выглядит оно текстовой кнопкой: разница между состоянием и действием обязана читаться глазами. Выходные красятся своим цветом лишь в нажатом виде, чтобы спокойный ряд не рябил.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Togglegroup004Props = Omit<
ComponentPropsWithoutRef<"section">,
"children" | "onChange"
> & {
label?: string
hint?: string
defaultValue?: string[]
onChange?: (value: string[]) => void
accent?: string
}
// Идея компонента: фильтр по дням недели множественным выбором. Кружок — это
// toggle: нажат или нет, седьмого состояния не бывает. Рядом стоит обычная
// кнопка «Будни» — она не toggle, а действие над выбором, и выглядит иначе,
// чтобы разница между состоянием и действием читалась глазами.
const STYLES = `
:where([data-vibeui-block="togglegroup-004"]){
--vibeui-togglegroup-004-bg:oklch(1 0 0);
--vibeui-togglegroup-004-fg:oklch(0.22 0.014 265);
--vibeui-togglegroup-004-muted:oklch(0.55 0.014 265);
--vibeui-togglegroup-004-border:oklch(0.9 0.006 265);
--vibeui-togglegroup-004-surface:oklch(0.97 0.004 265);
--vibeui-togglegroup-004-accent:oklch(0.55 0.16 145);
--vibeui-togglegroup-004-weekend:oklch(0.6 0.16 25);
--vibeui-togglegroup-004-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="togglegroup-004"]{
box-sizing:border-box;display:flex;flex-direction:column;gap:0.625rem;
width:100%;max-width:23rem;padding:0.875rem;
border:1px solid var(--vibeui-togglegroup-004-border);border-radius:0.875rem;
background:var(--vibeui-togglegroup-004-bg);color:var(--vibeui-togglegroup-004-fg);
font-family:var(--vibeui-togglegroup-004-font);
}
[data-vibeui-block="togglegroup-004"] *{box-sizing:border-box}
[data-vibeui-block="togglegroup-004"] [data-part="head"]{
display:flex;align-items:baseline;justify-content:space-between;gap:0.75rem;
}
[data-vibeui-block="togglegroup-004"] h3{margin:0;font-size:0.875rem;font-weight:650}
[data-vibeui-block="togglegroup-004"] [data-part="preset"]{
appearance:none;cursor:pointer;font:inherit;border:0;background:none;padding:0;
color:var(--vibeui-togglegroup-004-accent);
font-size:0.75rem;font-weight:600;text-decoration:underline;text-underline-offset:0.2em;
}
[data-vibeui-block="togglegroup-004"] [data-part="preset"]:focus-visible{
outline:2px solid var(--vibeui-togglegroup-004-accent);outline-offset:2px;border-radius:0.25rem;
}
[data-vibeui-block="togglegroup-004"] [data-part="group"]{
display:flex;flex-wrap:wrap;gap:0.375rem;
}
[data-vibeui-block="togglegroup-004"] [data-part="day"]{
appearance:none;cursor:pointer;font:inherit;
display:inline-flex;align-items:center;justify-content:center;
width:2.375rem;height:2.375rem;padding:0;
border:1px solid var(--vibeui-togglegroup-004-border);border-radius:50%;
background:var(--vibeui-togglegroup-004-bg);color:var(--vibeui-togglegroup-004-muted);
font-size:0.8125rem;font-weight:650;line-height:1;
transition:background-color .15s ease,color .15s ease,border-color .15s ease;
}
[data-vibeui-block="togglegroup-004"] [data-part="day"]:hover{background:var(--vibeui-togglegroup-004-surface)}
[data-vibeui-block="togglegroup-004"] [data-part="day"]:focus-visible{
outline:2px solid var(--vibeui-togglegroup-004-accent);outline-offset:2px;
}
[data-vibeui-block="togglegroup-004"] [data-part="day"][aria-pressed="true"]{
background:var(--vibeui-togglegroup-004-accent);
border-color:var(--vibeui-togglegroup-004-accent);
color:oklch(0.99 0 0);
}
/* Выходные красятся своим цветом только в нажатом виде: в спокойном
состоянии семь разноцветных кружков читались бы как семь разных сущностей. */
[data-vibeui-block="togglegroup-004"] [data-part="day"][data-weekend="true"][aria-pressed="true"]{
background:var(--vibeui-togglegroup-004-weekend);
border-color:var(--vibeui-togglegroup-004-weekend);
}
[data-vibeui-block="togglegroup-004"] [data-part="summary"]{
margin:0;font-size:0.75rem;line-height:1.4;color:var(--vibeui-togglegroup-004-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="togglegroup-004"] *{animation:none!important;transition:none!important}}
`
const DAYS = [
{ id: "mon", short: "Пн", full: "Понедельник", weekend: false },
{ id: "tue", short: "Вт", full: "Вторник", weekend: false },
{ id: "wed", short: "Ср", full: "Среда", weekend: false },
{ id: "thu", short: "Чт", full: "Четверг", weekend: false },
{ id: "fri", short: "Пт", full: "Пятница", weekend: false },
{ id: "sat", short: "Сб", full: "Суббота", weekend: true },
{ id: "sun", short: "Вс", full: "Воскресенье", weekend: true },
]
function plural(count: number) {
const tail = count % 100
if (tail > 10 && tail < 20) {
return "дней"
}
const last = count % 10
if (last === 1) {
return "день"
}
if (last > 1 && last < 5) {
return "дня"
}
return "дней"
}
/**
* Фильтр по дням недели: множественный выбор кружками-тумблерами и живая
* строка итога. Один файл, ноль зависимостей, собственная палитра.
*/
export function Togglegroup004({
label = "Дни доставки",
hint = "Курьер приезжает только в отмеченные дни.",
defaultValue = ["mon", "wed", "fri"],
onChange,
accent,
className,
style,
...props
}: Togglegroup004Props) {
const [value, setValue] = useState<string[]>(defaultValue)
const palette = {
...(accent ? { "--vibeui-togglegroup-004-accent": accent } : null),
...style,
} as CSSProperties
const apply = (next: string[]) => {
setValue(next)
onChange?.(next)
}
const chosen = DAYS.filter((day) => value.includes(day.id))
return (
<>
<style href="vibeui-togglegroup-004" precedence="medium">
{STYLES}
</style>
<section
{...props}
data-vibeui-block="togglegroup-004"
className={className}
style={palette}
>
<div data-part="head">
<h3>{label}</h3>
<button
type="button"
data-part="preset"
onClick={() => apply(["mon", "tue", "wed", "thu", "fri"])}
>
Только будни
</button>
</div>
<div data-part="group" role="group" aria-label={label}>
{DAYS.map((day) => (
<button
key={day.id}
type="button"
data-part="day"
data-weekend={day.weekend}
aria-pressed={value.includes(day.id)}
aria-label={day.full}
onClick={() =>
apply(
value.includes(day.id)
? value.filter((item) => item !== day.id)
: [...value, day.id],
)
}
>
{day.short}
</button>
))}
</div>
<p data-part="summary" role="status">
{chosen.length === 0
? "Ни один день не выбран — доставки не будет."
: `${chosen.length} ${plural(chosen.length)}: ${chosen
.map((day) => day.short)
.join(", ")}.`}
</p>
<p data-part="summary">{hint}</p>
</section>
</>
)
}