Skip to content

Update select.mdx docs to show on ios #402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 62 additions & 46 deletions apps/docs/src/content/docs/components/select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,54 +66,70 @@ Presents a selection of options for the user to choose from, activated by a butt
```tsx
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from '~/components/ui/select';
import { FullWindowOverlay } from 'react-native-screens';
import { Platform, View } from 'react-native';
import { PortalHost } from '@rn-primitives/portal';
const IOS_PORTAL_HOST_NAME = 'modal-example';

export default function Example() {
const insets = useSafeAreaInsets();
const contentInsets = {
top: insets.top,
bottom: insets.bottom,
left: 12,
right: 12,
};

function Example() {
const insets = useSafeAreaInsets();
const contentInsets = {
top: insets.top,
bottom: insets.bottom,
left: 12,
right: 12,
};

return (
<Select defaultValue={{ value: 'apple', label: 'Apple' }}>
<SelectTrigger className='w-[250px]'>
<SelectValue
className='text-foreground text-sm native:text-lg'
placeholder='Select a fruit'
/>
</SelectTrigger>
<SelectContent insets={contentInsets} className='w-[250px]'>
<SelectGroup>
<SelectLabel>Fruits</SelectLabel>
<SelectItem label='Apple' value='apple'>
Apple
</SelectItem>
<SelectItem label='Banana' value='banana'>
Banana
</SelectItem>
<SelectItem label='Blueberry' value='blueberry'>
Blueberry
</SelectItem>
<SelectItem label='Grapes' value='grapes'>
Grapes
</SelectItem>
<SelectItem label='Pineapple' value='pineapple'>
Pineapple
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
);
return (
<>
<Select defaultValue={{ value: 'apple', label: 'Apple' }}>
<SelectTrigger className='w-[250px]'>
<SelectValue
className='text-foreground text-sm native:text-lg'
placeholder='Select a fruit'
/>
</SelectTrigger>
<SelectContent
insets={contentInsets}
className='w-[250px]'
portalHost={Platform.select({ ios: IOS_PORTAL_HOST_NAME })}
sideOffset={Platform.select({ ios: 16 })}
>
<SelectGroup>
<SelectLabel>Fruits</SelectLabel>
<SelectItem label='Apple' value='apple'>
Apple
</SelectItem>
<SelectItem label='Banana' value='banana'>
Banana
</SelectItem>
<SelectItem label='Blueberry' value='blueberry'>
Blueberry
</SelectItem>
<SelectItem label='Grapes' value='grapes'>
Grapes
</SelectItem>
<SelectItem label='Pineapple' value='pineapple'>
Pineapple
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
{Platform.OS === 'ios' && (
<FullWindowOverlay>
<PortalHost name={IOS_PORTAL_HOST_NAME} />
</FullWindowOverlay>
)}
</>
);
}
```

Expand Down