Sizing & Defaults
Glyx follows one principle everywhere: use the defaults or override them — never fight them. This page is the contract. If a component ever behaves differently, that's a bug.
Flex semantics (React Native, not CSS)
flex: N means grow N, shrink 1, basis 0, no automatic minimum size — exactly like React Native/Yoga:
- A
flex: 1chain inside a fixed window always fits the window; content never forces it taller. - A
flex: 1ScrollView gets the leftover space and scrolls its overflow. - CSS's "flex item can't shrink below its content" rule does not apply. You never need
minHeight: 0hacks.
The layout root is always exactly the window size, so flex: 1 chains are reliable from the top down.
Views
| Property | Default |
|---|---|
| direction | column |
| alignItems | stretch |
| justifyContent | flex-start |
| margin / padding | 0 |
| width / height | content-sized |
A bare View in a column stretches horizontally (alignItems stretch) and sizes to its content vertically — same as a web div.
Text
Text auto-sizes: single line when there's room, wraps when constrained, never needs an explicit width. Alignment is left by default; textAlign: 'center' | 'right' are opt-in.
ScrollView
Give it a size (flex: 1 or height) — it clips and scrolls whatever overflows. Content height is measured natively from real layout, so auto-sized children scroll correctly. Wheel, scrollbar thumb drag, track-click jump, and keyboard navigation all work out of the box. Never set a ScrollView's width to something larger than its container: its hit area follows its layout rect.
Form controls — the width cascade
Every fixed-footprint control (TextInput, Select, DatePicker, TimePicker, DateTimePicker) resolves its width with the same three-step cascade:
- Explicit
widthprop — always wins. - Width-affecting style — if your
stylecontains any ofwidth,flex,flexGrow,minWidth, oralignSelf, the control applies no default at all; layout decides. - Fallback default — with nothing else, the control renders compact (
alignSelf: 'flex-start') at its default width.
| Control | Default width |
|---|---|
TextInput / PasswordInput / NumericInput | 240 |
Select | 240 |
DatePicker | 240 |
TimePicker | 160 |
DateTimePicker | 280 |
Slider | 200 (measures its real laid-out width — thumb and clicks always agree) |
To make any control fill its container, one style is enough:
<Select options={opts} style={{ alignSelf: 'stretch' }} /> // full width in a column
<TextInput style={{ flex: 1 }} /> // share a rowHeights
- Single-line
TextInput: 44px unlessheightis given. - Multiline
TextInput: auto-grows with content betweenminLines(default 3) andmaxLines(default 10); an explicitheightopts out and the field scrolls instead (wheel, scrollbar, caret-follow). Button,Checkbox,Switch, chips: content-sized — padding, not fixed heights.
One chrome per field
TextField (in @glyx-dev/design) draws exactly one bordered surface. Bare, the input itself is the box; with leftIcon/rightIcon the row container is the box and the inner input goes transparent. If you see nested boxes, something is double-styling — pass inputStyle overrides rather than wrapping inputs in your own bordered views.
Theme contrast rules
colors.surfaceis for cards/panels and input interiors — it always contrasts withcolors.bg.colors.borderis visible against bothbgandsurface.colors.surfaceHoveris for list-row hover states.- Never use
colors.bgas a control's interior — it disappears into the page.