From d3c967c857a82361f651e939650760f14f1f6f4b Mon Sep 17 00:00:00 2001 From: justblender Date: Fri, 1 Mar 2024 20:38:05 +0300 Subject: [PATCH] docs: tell about a secondary `layout` argument in `createStyleSheet` --- .../content/docs/reference/create-stylesheet.mdx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/src/content/docs/reference/create-stylesheet.mdx b/docs/src/content/docs/reference/create-stylesheet.mdx index 83b9dcf7..19248f8d 100644 --- a/docs/src/content/docs/reference/create-stylesheet.mdx +++ b/docs/src/content/docs/reference/create-stylesheet.mdx @@ -64,6 +64,22 @@ const stylesheet = createStyleSheet(theme => ({ })) ``` +In addition to the `theme` argument, you can also accept the `layout` argument when passing a function, which can be useful to access screen orientation, dimensions, insets, and more. + +```ts /theme/ +const stylesheet = createStyleSheet((theme, layout) => ({ + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + paddingTop: layout.insets.top, + backgroundColor: layout.orientation === 'portrait' + ? theme.colors.accent + : theme.colors.oak + }, +})) +``` + Importantly, you'll receive the same TypeScript hints as with `StyleSheet.create`!