UseWindowSize
Last updated: 3.0.0 (04/07/2024)
Usage
import { useWindowSize, Text } from "@valence-ui/core";
function MyComponent() {
const { width, height } = useWindowSize();
return (
<Text>
Window size: {width}px Γ {height}px
</Text>
)
}Responsive layouts
import { useWindowSize, Flex, Text } from "@valence-ui/core";
function MyComponent() {
const { width } = useWindowSize();
const columns = width > 1200 ? 4 : width > 800 ? 3 : width > 500 ? 2 : 1;
return (
<Flex>
<Text>
Showing {columns} columns
</Text>
</Flex>
)
}Return type
Attribute
Type
Description
Last updated