Files

190 lines
4.5 KiB
CSS

/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix. */
/* ComboBox styles */
.hv-combo-box {
@apply flex flex-col gap-1;
&[data-invalid="true"],
&[aria-invalid="true"] {
[data-slot="description"] {
@apply hidden;
}
}
[data-slot="label"] {
@apply w-fit;
}
[data-slot="input"] {
@apply min-w-0 flex-1;
/* Add inline-end padding when trigger is present */
&:has(+ .hv-combo-box__trigger) {
@apply pe-7;
}
/* Focus state (input.css only has focus-visible, but hv-combo-box also needs focus) */
&:focus,
&[data-focus] {
@apply status-focused-field;
border-color: var(--field-border-focus);
background-color: var(--field-focus);
}
/* Disabled state */
&:disabled,
&[data-disabled],
&[aria-disabled="true"] {
@apply status-disabled;
}
}
}
.hv-combo-box__input-group {
@apply relative isolate inline-flex items-center;
}
.hv-combo-box__value {
@apply text-sm wrap-break-word text-field-foreground empty:hidden;
&[data-placeholder="true"] {
@apply text-field-placeholder;
}
/* Removes the list-box-item indicator element from the hv-combo-box value */
[data-slot="list-box-item-indicator"] {
@apply hidden;
}
}
.hv-combo-box__trigger {
@apply absolute end-0 top-1/2 flex h-full shrink-0 -translate-y-1/2 cursor-pointer items-center justify-center pe-2 text-field-placeholder transition duration-150 no-highlight;
/* Remove default button styles */
@apply border-none bg-transparent outline-none;
/* Hover state */
@media (hover: hover) {
&:hover,
&[data-hovered="true"] {
@apply text-field-foreground;
}
}
/* Focus visible state */
&:focus-visible:not([data-focused]),
&[data-focus-visible="true"] {
@apply rounded ring-2 ring-focus ring-offset-2 ring-offset-background outline-none;
}
/* Pressed state */
&[data-pressed="true"] {
@apply opacity-70;
}
/* Disabled state */
&:disabled,
&[data-disabled],
&[aria-disabled="true"] {
@apply cursor-not-allowed opacity-50;
}
[data-slot="combo-box-trigger-default-icon"] {
@apply size-4 transition-transform duration-150 motion-reduce:transition-none;
}
/* Rotate icon when trigger is open */
&[data-open="true"] [data-slot="combo-box-trigger-default-icon"] {
@apply rotate-180;
}
}
/* Similar to popover content styles */
.hv-combo-box__popover {
@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-placement="top"] {
@apply slide-in-from-bottom-1;
}
&[data-placement="bottom"] {
@apply slide-in-from-top-1;
}
&[data-placement="left"] {
@apply slide-in-from-right-1;
}
&[data-placement="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-placement="bottom"] [data-slot="popover-overlay-arrow"] {
rotate: 180deg;
}
&[data-placement="left"] [data-slot="popover-overlay-arrow"] {
rotate: -90deg;
}
&[data-placement="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 hv-combo-box is single-select, we don't need to animate the checkmark */
[data-slot="list-box-item-indicator--checkmark"] {
@apply transition-none;
}
}
}
/* Full width modifier */
.hv-combo-box--full-width {
@apply w-full;
}
.hv-combo-box__input-group--full-width {
@apply w-full;
}