Skip to content

Commit

Permalink
Expose SelectValue component (#3746)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohaz committed May 27, 2024
1 parent 13d3716 commit 0f392a7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .changeset/3746-select-value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@ariakit/react": patch
---

New `SelectValue` component

A [`SelectValue`](https://ariakit.org/reference/select-value) component is now available. This is a _value_ component, which means it doesn't render any DOM elements and, as a result, doesn't take HTML props. Optionally, it can use a [`fallback`](https://ariakit.org/reference/select-value#fallback) prop as a default value if the store's [`value`](https://ariakit.org/reference/use-select-store#value) is `undefined`:

```jsx
<Select>
<SelectValue fallback="Select a value" />
<SelectArrow />
</Select>
```
1 change: 1 addition & 0 deletions components/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ useSelectContext()
<SelectProvider>
<SelectLabel />
<Select>
<SelectValue />
<SelectArrow />
</Select>
<SelectPopover>
Expand Down
3 changes: 1 addition & 2 deletions examples/select-combobox-tab/select.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as Ariakit from "@ariakit/react";
import { SelectValue } from "@ariakit/react-core/select/select-value";
import clsx from "clsx";
import * as React from "react";

Expand Down Expand Up @@ -58,7 +57,7 @@ export function Select({
)}
>
{icon}
<div className="truncate">{text || <SelectValue />}</div>
<div className="truncate">{text || <Ariakit.SelectValue />}</div>
<Ariakit.SelectArrow />
</Ariakit.Select>
<Ariakit.SelectPopover
Expand Down
3 changes: 3 additions & 0 deletions packages/ariakit-react/src/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export { SelectList } from "@ariakit/react-core/select/select-list";
export { SelectPopover } from "@ariakit/react-core/select/select-popover";
export { SelectRow } from "@ariakit/react-core/select/select-row";
export { SelectSeparator } from "@ariakit/react-core/select/select-separator";
export { SelectValue } from "@ariakit/react-core/select/select-value";

export type {
SelectStoreProps,
Expand Down Expand Up @@ -87,3 +88,5 @@ export type {
SelectSeparatorOptions,
SelectSeparatorProps,
} from "@ariakit/react-core/select/select-separator";

export type { SelectValueProps } from "@ariakit/react-core/select/select-value";
2 changes: 1 addition & 1 deletion website/components/playground-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
SelectItemCheck,
SelectPopover,
SelectProvider,
SelectValue,
Toolbar,
ToolbarItem,
} from "@ariakit/react";
import { SelectValue } from "@ariakit/react-core/select/select-value";
import { twJoin } from "tailwind-merge";
import { AuthEnabled } from "./auth.tsx";
import { CopyToClipboard } from "./copy-to-clipboard.tsx";
Expand Down

0 comments on commit 0f392a7

Please sign in to comment.