Skip to content

The Open Standard for Generative UI

4.0 KB
Raw Blame
@use "../../cssUtils" as cssUtils;
@use "../menu";

.openui-select-trigger {
  box-sizing: border-box;
  background-color: cssUtils.$highlight-subtle;
  color: cssUtils.$text-neutral-primary;
  @include cssUtils.typography(body, default);
  border: 1px solid cssUtils.$border-default;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: cssUtils.$space-s;

  &:hover {
    background: cssUtils.$highlight;
    border-color: cssUtils.$border-interactive;
    color: cssUtils.$text-neutral-secondary;
    &:not([data-placeholder]) {
      color: cssUtils.$text-neutral-primary;
    }
  }

  &:disabled {
    background-color: cssUtils.$highlight-subtle;
    color: cssUtils.$text-neutral-tertiary;
    border-color: cssUtils.$border-default;
    cursor: not-allowed;
  }

  &[data-state="open"] {
    border-color: cssUtils.$border-interactive;
    background-color: cssUtils.$highlight;
  }
  &[data-placeholder] {
    color: cssUtils.$text-neutral-secondary;
  }

  &-sm {
    @include cssUtils.typography(body, small);
    padding: calc(cssUtils.$space-xs - 1.5px) cssUtils.$space-s;
    border-radius: calc(cssUtils.$radius-s + 1px);
  }
  &-md {
    padding: calc(cssUtils.$space-xs - 1px) calc(cssUtils.$space-m - 1px);
    border-radius: cssUtils.$radius-m;
  }
  &-lg {
    padding: calc(cssUtils.$space-s - 1px) cssUtils.$space-m;
    border-radius: cssUtils.$radius-l;
  }
  &-icon {
    height: 16px;
    width: 16px;
  }
}

.openui-select-trigger svg {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.openui-select-trigger[data-state="open"] svg {
  transform: rotate(180deg);
}

.openui-select-content {
  box-sizing: border-box;
  position: relative;
  z-index: 99999;
  max-height: 372px;
  min-width: var(--radix-select-trigger-width);
  overflow: hidden;
  @include menu.surface;
  padding: 0; // the viewport carries the vertical padding
  color: cssUtils.$text-neutral-primary;
  transform-origin: top center;
  animation: select-show 0.18s ease-out forwards;
}

.openui-select-content-sm {
  .openui-select-label,
  .openui-select-item,
  .openui-select-item-text,
  .openui-select-item-text-value {
    @include cssUtils.typography(body, small);
  }
}

@keyframes select-show {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.openui-select-viewport {
  box-sizing: border-box;
  padding: menu.$gutter 0;

  &[data-position="popper"] {
    width: 100%;
  }
}

.openui-select-group {
  display: flex;
  flex-direction: column;
  gap: cssUtils.$space-3xs;
}

.openui-select-label {
  box-sizing: border-box;
  @include cssUtils.typography(body, default);
  @include menu.label;
}

.openui-select-item {
  box-sizing: border-box;
  position: relative;
  display: flex;
  cursor: default;
  user-select: none;
  align-items: center;
  justify-content: space-between;
  @include cssUtils.typography(body, default);
  @include menu.item;
  color: cssUtils.$text-neutral-primary;

  // Room for the check indicator on the trailing edge.
  &--with-tick {
    padding-right: cssUtils.$space-xl;
  }

  // States
  &[data-disabled] {
    pointer-events: none;
    opacity: 0.5;
  }

  &[data-highlighted] {
    color: cssUtils.$text-neutral-primary;
  }

  &:not([data-state="checked"]):hover {
    background-color: cssUtils.$highlight;
    color: cssUtils.$text-neutral-primary;
  }

  &:focus {
    background-color: cssUtils.$highlight;
    color: cssUtils.$text-neutral-primary;
  }

  &[data-state="checked"] {
    background-color: cssUtils.$highlight;
  }

  // Check indicator
  &-check-wrapper {
    position: absolute;
    right: 8px;
    height: 14px;
    width: 14px;
  }

  &-check-icon {
    height: 16px;
    width: 16px;
  }

  // Text content
  &-text {
    flex: 1;
    @include cssUtils.typography(body, default);
    color: cssUtils.$text-neutral-secondary;
  }

  &-value {
    color: cssUtils.$text-neutral-secondary;
  }
}

.openui-select-separator {
  box-sizing: border-box;
  @include menu.separator;
  height: 1px;
  border-top: 1px solid cssUtils.$border-default;
}