Happeo UIkit logo
Components
Home
Packages
AlertsAvatarBannersBreadcrumbsButtonsButtonsDS3CardColor PickerColorsContent RendererEmojisFile IconFile PickerForm ElementsIcons AppIcons FileIcons FlagIcons LegacyIcons SymbolImage CarouselImage CropperImage GridLayoutScreen SizesMedia QueriesGridMarginsPaddingsSpacersPopoverListLoadersMenusModalsNavigationThemeToastTypography

Layout

This guideline part has the core layout principles and values.

Screen Sizes

There are five different screen sizes.

  • XS, a.k.a Mobile Small: 0px -> 359px
  • SM, a.k.a Mobile Standard: 360px -> 416px
  • MD, a.k.a Tablet: 417px -> 1024px
  • LG, a.k.a Small Laptop: 1025px -> 1280px
  • XL, a.k.a Laptop: 1281px -> 1440px
  • XXL, a.k.a Desktop: 1441 -> 1920px

Media Queries

Write in "Mobile First": without a media query you define the smallest screen. You can then add more elements with media.min[size] query, see example.

import styled from "styled-components";
import {media} from "@happeouikit/layout
const StyledDiv = styled.div`
width: 100%;
${media.min.md`
max-width: 1812px;
`}
`;

To only show something on exact screen size use media.only[size].

const StyledDiv = styled.div`
width: 100%;
${media.only.md`
display: none;
`}
`;

NOTE: For tricky situations there is also media.max[size], but please prefer the Mobile First approach, and use the minimum value to keep the code consistent.

Grid

Grid is based on Bootstrap 12 column grid. See Bootstrap documentation for extensive amount of examples. Basically the Bootstrap classes has been transformed to React Components: <Container>, <Row> and <Col>. Each of the components takes in the modifications as parameters, not with classes as in Bootstrap documentation.

For example:

If you want to have for example a fixed width sidebar and then columns for content. Do not use grid for the sidebar+content layout, but use custom elements with fixed with. Inside the sidebar and/or content you can then use a grid.

<Container />

fluid
bool

<Row />

alignItems
"start" │ "end" │ "center" │ "baseline" │ "stretch"
smAlignItems
"start" │ "end" │ "center" │ "baseline" │ "stretch"
mdAlignItems
"start" │ "end" │ "center" │ "baseline" │ "stretch"
lgAlignItems
"start" │ "end" │ "center" │ "baseline" │ "stretch"
xlAlignItems
"start" │ "end" │ "center" │ "baseline" │ "stretch"
xxlAlignItems
"start" │ "end" │ "center" │ "baseline" │ "stretch"
justifyContent
"start" │ "end" │ "center" │ "between" │ "around"
smJustifyContent
"start" │ "end" │ "center" │ "between" │ "around"
mdJustifyContent
"start" │ "end" │ "center" │ "between" │ "around"
lgJustifyContent
"start" │ "end" │ "center" │ "between" │ "around"
xlJustifyContent
"start" │ "end" │ "center" │ "between" │ "around"
xxlJustifyContent
"start" │ "end" │ "center" │ "between" │ "around"

<Col />

noGutter
bool
col
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
offset
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
auto
bool
alignSelf
"auto" │ "start" │ "end" │ "center" │ "baseline" │ "stretch"
order
"first" │ "last" │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11
hiddenXsDown
bool
hiddenXsUp
bool
sm
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
smOffset
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
smAuto
bool
smAlignSelf
"auto" │ "start" │ "end" │ "center" │ "baseline" │ "stretch"
smOrder
"first" │ "last" │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11
hiddenSmDown
bool
hiddenSmUp
bool
md
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
mdOffset
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
mdAuto
bool
mdAlignSelf
"auto" │ "start" │ "end" │ "center" │ "baseline" │ "stretch"
mdOrder
"first" │ "last" │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11
hiddenMdDown
bool
hiddenMdUp
bool
lg
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
lgOffset
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
lgAuto
bool
lgAlignSelf
"auto" │ "start" │ "end" │ "center" │ "baseline" │ "stretch"
lgOrder
"first" │ "last" │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11
hiddenLgDown
bool
hiddenLgUp
bool
xl
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
xlOffset
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
xlAuto
bool
xlAlignSelf
"auto" │ "start" │ "end" │ "center" │ "baseline" │ "stretch"
xlOrder
"first" │ "last" │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11
hiddenXlDown
bool
hiddenXlUp
bool
xxl
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
xxlOffset
1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12
xxlAuto
bool
xxlAlignSelf
"auto" │ "start" │ "end" │ "center" │ "baseline" │ "stretch"
xxlOrder
"first" │ "last" │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11
hiddenXxlDown
bool
hiddenXxlUp
bool

Margins

margin100

margin200

margin300

margin400

margin500

margin600

margin700

margin800

margin900

margin1000

Paddings

padding100

padding200

padding300

padding400

padding600

padding800

Spacers

Spacer component accepts width and height, both will default to 16px if value not given.

Popover

Popover allows to create elements that float in reference to a anchor element. You can also use the popover ref to add

Props

  • anchor = Anchor element ref
  • anchorPosition = "top left" | "top right" | "bottom left" | "bottom right"
  • children = Child elements

Popover code example with useOnClickOutside

const PopoverExample = () => {
const [isOpen, setIsOpen] = useState(false);
const anchor = useRef();
const popover = useRef();
hooks.useOnClickOutside(popover, () => {
if (isOpen) {
setIsOpen(false);
}
});
return (
<div ref={anchor}>
<button
type="button"
onClick={() => setIsOpen((prevValue) => !prevValue)}
>
clickedi
</button>
{isOpen && (
<Popover anchor={anchor} ref={popover}>
<div>
<p>I am in a popover lol</p>
</div>
</Popover>
)}
</div>
);
};