Layout changes from Anvil → Anvil2
Summary
- Enable easy use of Flexbox and CSS Grid
- Two new component – Flex and Grid
- All Anvil2 components have some control over layout using layout utils props
- Simplified APIs
- Flexibility and responsiveness baked-in
Page component updates
See Anvil2 Page Implementation Docs- Simplified API
- Headers, footers, and action toolbars should now be created independently as part of the layout
- Sidebar and Panel are now sub-components
- Background color can be controlled using CSS (
styleorclassName) - Better responsive behavior coming soon!
Layout component updates
See Anvil2 Layout Implementation Docs- Simplified API with
LayoutandLayout.Itemused to create columns - Responsiveness built-in, and customizable
- Three density variants available using
variantprop:"default","narrow", and"wide"
Column structure and responsive behavior
Layouts use a 12-column structure that reduces columns based on the size of the layout. Note that the values below are based on the width of the Layout, not the entire screen (using container queries). This is important if the page includes a sidebar or panel.- On
smscreens (and below), there are four columns - On
mdscreens and up, there are twelve columns
span value at certain breakpoints (and higher).
New layout features in Anvil2
Flex and Grid components
See the Flex Implementation Docs and Grid Implementation Docs.Flex is similar to Stack, with some minor differences. A Flex can be used both as a flex container and item, so instead of using Stack.Item, use another Flex or another Anvil2 component. This greatly reduces the amount of code required to build flex layouts!
Anvil (legacy) example
Anvil2 example
Grid component can be used to create CSS Grid layouts (not to be confused with the Anvil Grid). Grid components can also be used as grid containers or items, and any Anvil2 component can use special grid props to control its columns and rows.
Responsive props of Flex and Grid
Similar to theLayout.Item, responsive props are also available to override any of the Flex and Grid props at different breakpoints.
Layout Props
See Layout Props Utilities documentation. All Anvil2 components other thanPage and Layout extend Layout type, which enable them to control various flex and grid properties. props at different breakpoints.
Layout type only apply to flex or grid containers. The Card component is a flex container by default. Other components would need display: flex or display: grid added to use the following props: