/* Adapted from HeroUI ce90ea3, Apache-2.0. See third-party/HEROUI-LICENSE. * Modified: hv- namespace, Reka placement state. */ /* Select styles */ .hv-select { @apply flex flex-col gap-1; &[data-invalid="true"], &[aria-invalid="true"] { [data-slot="description"] { @apply hidden; } } [data-slot="label"] { @apply w-fit; } } .hv-select__trigger { @apply relative isolate inline-flex min-h-9 rounded-field border bg-field px-3 py-2 text-sm text-field-foreground shadow-field outline-none select-none no-highlight; /** * Transitions * CRITICAL: motion-reduce must be AFTER transition for correct override specificity */ transition: background-color 150ms var(--ease-smooth), border-color 150ms var(--ease-smooth), box-shadow 150ms var(--ease-out); @apply motion-reduce:transition-none; /* Cursor */ cursor: var(--cursor-interactive); border-width: var(--border-width-field); border-color: var(--field-border); /* Add inline-end padding when indicator is present */ &:has(.hv-select__indicator) { @apply pe-7; } /* Hover state - exclude when clear button is hovered to prevent double hover effect */ @media (hover: hover) { &:hover:not(:has(.hv-select__clear-button:hover)), &[data-hovered="true"]:not(:has(.hv-select__clear-button:hover)) { @apply bg-field-hover; border-color: var(--field-border-hover); } } /* Focus visible state */ &:focus-visible:not([data-focused]), &[data-focus-visible="true"] { @apply status-focused; border-color: var(--field-border-focus); background-color: var(--field-focus); } /* Focus state */ &:focus, &[data-focus="true"] { } /* Invalid state */ .hv-select[data-invalid="true"] &, .hv-select[aria-invalid="true"] & { @apply status-invalid-field; background-color: var(--field-focus); } /* Disabled state */ &:disabled, &[data-disabled="true"], &[aria-disabled="true"] { @apply status-disabled; } } /* Variant property definitions */ .hv-select--primary { /* Default styles */ } .hv-select--secondary .hv-select__trigger { @apply shadow-none; background-color: var(--select-trigger-bg); --select-trigger-bg: var(--default); --select-trigger-bg-hover: var(--default-hover); --select-trigger-bg-focus: var(--default); /* Exclude when clear button is hovered to prevent double hover effect */ @media (hover: hover) { &:hover:not(:has(.hv-select__clear-button:hover)), &[data-hovered="true"]:not(:has(.hv-select__clear-button:hover)) { background-color: var(--select-trigger-bg-hover); } } &:focus-visible:not([data-focused]), &[data-focus-visible="true"] { background-color: var(--select-trigger-bg-focus); } &:focus, &[data-focus="true"] { } .hv-select[data-invalid="true"] &, .hv-select[aria-invalid="true"] & { background-color: var(--select-trigger-bg-focus); } } .hv-select__value { @apply flex-1 text-start text-base wrap-break-word text-current sm:text-sm; &[data-placeholder="true"] { @apply text-field-placeholder; } /* Removes the list-box-item indicator element from the select value*/ [data-slot="list-box-item-indicator"] { @apply hidden; } } /* Clear Button styles */ .hv-select__clear-button { @apply relative isolate inline-flex size-5 shrink-0 origin-center transform-gpu items-center justify-center self-center rounded-xl bg-transparent p-1 text-muted select-none no-highlight; /* Cursor */ cursor: var(--cursor-interactive); /** * The visible box stays at 20px so it fits inside the trigger's 36px min-height * without growing it. Expand the pointer target to the 24px floor in WCAG 2.5.8. */ &::after { @apply absolute -inset-0.5; content: ""; } /* Transition only when visible - disappears immediately when cleared */ &:not([data-empty="true"]) { transition: opacity 150ms var(--ease-smooth); @apply motion-reduce:transition-none; } &[data-empty="true"] { @apply pointer-events-none opacity-0; } [data-slot="select-clear-button-icon"] { @apply size-3.5; } @media (hover: hover) { &:hover, &[data-hovered="true"] { @apply bg-default-hover; } } &:active, &[data-pressed="true"] { transform: scale(0.93); } } .hv-select__indicator { @apply absolute inset-y-0 end-2 my-auto flex shrink-0 items-center justify-center text-field-placeholder transition duration-150; @media (prefers-reduced-motion: reduce) { transition: none; } &[data-open="true"] { @apply rotate-180; } &[data-slot="select-default-indicator"] { @apply size-4; } } /* Similar to popover content styles */ .hv-select__popover { /* RAC constrains overlays to available space; use Reka measurement variables. */ max-height: var(--reka-popover-content-available-height); max-width: var(--reka-popover-content-available-width); @apply min-w-(--trigger-width) origin-(--trigger-anchor-point) scroll-py-1 scrollbar overflow-y-auto overscroll-contain bg-overlay p-0 text-sm; border-radius: min(32px, var(--radius-3xl)); box-shadow: var(--overlay-shadow); /* Focus state */ &:focus-visible:not([data-focused]), &[data-focus-visible="true"] { @apply outline-none; } /* Entering animations */ &[data-entering="true"] { @apply animate-in duration-150 ease-smooth fade-in-0 zoom-in-95; /* Placement-specific translations */ &[data-side="top"] { @apply slide-in-from-bottom-1; } &[data-side="bottom"] { @apply slide-in-from-top-1; } &[data-side="left"] { @apply slide-in-from-right-1; } &[data-side="right"] { @apply slide-in-from-left-1; } } /* Exiting animations */ &[data-exiting="true"] { @apply animate-out duration-100 ease-smooth zoom-out-95 fade-out; /* Stays non-interactive while closing, even if the exit animation is interrupted. */ @apply pointer-events-none; } &[data-exiting="true"], &[data-entering="true"] { @apply transition-[opacity,transform] will-change-[opacity,transform]; @apply motion-reduce:animate-none motion-reduce:transition-none; } /* Arrow styling */ & [data-slot="popover-overlay-arrow"] { fill: var(--overlay); } /* Arrow rotation based on placement */ &[data-side="bottom"] [data-slot="popover-overlay-arrow"] { rotate: 180deg; } &[data-side="left"] [data-slot="popover-overlay-arrow"] { rotate: -90deg; } &[data-side="right"] [data-slot="popover-overlay-arrow"] { rotate: 90deg; } /* Listbox styles */ [data-slot="list-box"] { @apply p-1.5 outline-none; } [data-slot="list-box-item"] { @apply px-2.5; } /* As the popover closes fast in single-select mode, the default item indicator transition is not even visible - so we disable it only for single-select */ [data-slot="list-box"]:not([aria-multiselectable="true"]) [data-slot="list-box-item-indicator"], [data-slot="list-box"]:not([aria-multiselectable="true"]) [data-slot="list-box-item-indicator"] [data-slot="list-box-item-indicator--checkmark"] { @apply transition-none; } } /* Full width modifier */ .hv-select--full-width { @apply w-full; } .hv-select__trigger--full-width { @apply w-full; }