Skip to main content

Content

The Content component is a scrollable container for your main content with automatic keyboard avoidance and pull-to-refresh support.

Features​

  • πŸ“œ Automatic scrolling
  • ⌨️ Keyboard avoidance
  • πŸ”„ Pull-to-refresh
  • πŸ“ Flexible layout
  • πŸ“± Bottom menu spacing

Basic Usage​

import { Content } from '@tansuk/rott-ui';

<Content flex={1}>
{/* Your scrollable content */}
</Content>

Keyboard Avoidance​

<Content 
flex={1}
keyboardAvoidingView
keyboardVerticalOffset={100}
>
<Input name="email" type="email" />
<Input name="password" type="password" />
</Content>

Pull to Refresh​

import { useState } from 'react';

function MyScreen() {
const [refreshing, setRefreshing] = useState(false);

const onRefresh = async () => {
setRefreshing(true);
await fetchData();
setRefreshing(false);
};

return (
<Content
flex={1}
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}
>
{/* Content */}
</Content>
);
}

Horizontal Layout​

<Content row scrollEnabled>
<Item width={200} height={200} />
<Item width={200} height={200} />
</Content>

Props​

PropTypeDefaultDescription
childrenReactNode-Content
flexnumber-Flex value
rowbooleanfalseHorizontal layout
noPaddingbooleanfalseRemove padding
keyboardAvoidingViewbooleanfalseKeyboard avoidance
scrollEnabledbooleantrueEnable scrolling
refreshControlReactElement-Pull-to-refresh
hasBottomMenubooleanfalseBottom menu spacing

Example​

<Content 
flex={1}
keyboardAvoidingView
paddingHorizontal={24}
>
<Input name="name" type="default" label="Name" />
<Input name="email" type="email" label="Email" />
<Button variant="primary" marginTop={24}>Submit</Button>
</Content>