Style and Layout Props
Any CSS prop can be used in a component in Reflex. This is a short list of the most commonly used props. To see all CSS props that can be used check out this documentation.
Hyphens in CSS property names may be replaced by underscores to use as valid python identifiers, i.e. the CSS prop z-index
would be used as z_index
in Reflex.
Prop | Description | Potential Values |
---|---|---|
align | In a flex, it controls the alignment of items on the cross axis and in a grid layout, it controls the alignment of items on the block axis within their grid area (equivalent to align_items) | stretch center start end flex-start baseline |
backdrop_filter | Lets you apply graphical effects such as blurring or color shifting to the area behind an element | url(commonfilters.svg#filter) blur(2px) hue-rotate(120deg) drop-shadow(4px 4px 10px blue) |
background | Sets all background style properties at once, such as color, image, origin and size, or repeat method (equivalent to bg) | green radial-gradient(crimson, skyblue) no-repeat url('../lizard.png') |
background_color | Sets the background color of an element | brown rgb(255, 255, 128) #7499ee |
background_image | Sets one or more background images on an element | url('../lizard.png') linear-gradient(#e66465, #9198e5) |
border | Sets an element's border, which sets the values of border_width, border_style, and border_color. | solid dashed red thick double #32a1ce 4mm ridge rgba(211, 220, 50, .6) |
border_top / border_bottom / border_right / border_left | Sets an element's top / bottom / right / left border. It sets the values of border-(top / bottom / right / left)-width, border-(top / bottom / right / left)-style and border-(top / bottom / right / left)-color | solid dashed red thick double #32a1ce 4mm ridge rgba(211, 220, 50, .6) |
border_color | Sets the color of an element's border (each side can be set individually using border_top_color, border_right_color, border_bottom_color, and border_left_color) | red red #32a1ce red rgba(170, 50, 220, .6) green red yellow green transparent |
border_radius | Rounds the corners of an element's outer border edge and you can set a single radius to make circular corners, or two radii to make elliptical corners | 30px 25% 10% 10% 30% 50% 70% 10% / 50% |
border_width | Sets the width of an element's border | thick 1em 4px 1.25em 0 4px 8px 12px |
box_shadow | Adds shadow effects around an element's frame. You can set multiple effects separated by commas. A box shadow is described by X and Y offsets relative to the element, blur and spread radius, and color | 10px 5px 5px red 60px -16px teal 12px 12px 2px 1px rgba(0, 0, 255, .2) 3px 3px red, -1em 0 .4em olive; |
color | Sets the foreground color value of an element's text | rebeccapurple rgb(255, 255, 128) #00a400 |
display | Sets whether an element is treated as a block or inline box and the layout used for its children, such as flow layout, grid or flex | block inline inline-block flex inline-flex grid inline-grid flow-root |
flex_grow | Sets the flex grow factor, which specifies how much of the flex container's remaining space should be assigned to the flex item's main size | 1 2 3 |
height | Sets an element's height | 150px 20em 75% auto |
justify | Defines how the browser distributes space between and around content items along the main-axis of a flex container, and the inline axis of a grid container (equivalent to justify_content) | start center flex-start space-between space-around space-evenly stretch |
margin | Sets the margin area (creates extra space around an element) on all four sides of an element | 1em 5% 0 10px 50px 20px 10px 50px 20px 0 |
margin_x / margin_y | Sets the margin area (creates extra space around an element) along the x-axis / y-axis and a positive value places it farther from its neighbors, while a negative value places it closer | 1em 10% 10px |
margin_top / margin_right / margin_bottom / margin_left | Sets the margin area (creates extra space around an element) on the top / right / bottom / left of an element | 1em 10% 10px |
max_height / min_height | Sets the maximum / minimum height of an element and prevents the used value of the height property from becoming larger / smaller than the value specified for max_height / min_height | 150px 7em 75% |
max_width / min_width | Sets the maximum / minimum width of an element and prevents the used value of the width property from becoming larger / smaller than the value specified for max_width / min_width | 150px 20em 75% |
padding | Sets the padding area (creates extra space within an element) on all four sides of an element at once | 1em 10px 50px 30px 0 0 10px 50px 20px |
padding_x / padding_y | Creates extra space within an element along the x-axis / y-axis | 1em 10% 10px |
padding_top / padding_right / padding_bottom / padding_left | Sets the height of the padding area on the top / right / bottom / left of an element | 1em 10% 20px |
position | Sets how an element is positioned in a document and the top, right, bottom, and left properties determine the final location of positioned elements | static relative absolute fixed sticky |
text_align | Sets the horizontal alignment of the inline-level content inside a block element or table-cell box | start end center justify left right |
text_wrap | Controls how text inside an element is wrapped | wrap nowrap balance pretty |
top / bottom / right / left | Sets the vertical / horizontal position of a positioned element. It does not effect non-positioned elements. | 0 4em 10% 20px |
width | Sets an element's width | 150px 20em 75% auto |
white_space | Sets how white space inside an element is handled | normal nowrap pre break-spaces |
word_break | Sets whether line breaks appear wherever the text would otherwise overflow its content box | normal break-all keep-all break-word |
z_index | Sets the z-order of a positioned element and its descendants or flex and grid items, and overlapping elements with a larger z-index cover those with a smaller one | auto 1 5 200 |