generated from ginierlo/TeamProject
-
Notifications
You must be signed in to change notification settings - Fork 3
Tuto : CSS dans React
Melvyn M edited this page Feb 5, 2021
·
1 revision
We use rsuits for UI styles. Please use this component for Button, Input and all element given for us.
To style a div
or p
:
import styled from '@emotion/styled';
const MyCustomDiv = styled.div(
// style not depend on props
{
display: 'flex',
alignItems: 'center',
},
// style depent on props with function
// give the props
props => ({
backgroundColor: props.color,
}),
);
function Test() {
return (
// pass the props
<MyCustomDiv color="red">
<p>My element</p>
</MyCustomDiv>
);
}
OR
// warn : import must be exactly like this
// @emtion/core export too a css, but not the correct
import { css } from '@emotion/css';
function Test() {
return (
// create a class with this css values
<div
className={css({
display: 'flex',
alignItems: 'center',
})}>
<p>My element</p>
</div>
);
}
To style a Button
, Input
etc... from rsuite
:
import styled from '@emotion/styled';
import { Button } from 'rsuite';
const StyledButton = styled(Button)({
fontSize: 18,
});
function Test() {
return (
<StyledButton /* props of `Button` can be used here https://rsuitejs.com/components/button/*/
>
My button
</StyledButton>
);
}
- Home
- Rapport de travail Groupe "THYREL" sprint 1
- Rapport de travail Groupe "THYREL" sprint 2
- Rapport de travail Groupe "THYREL" sprint 3
- Rapport de travail Groupe "THYREL" sprint 4
- Rapport de travail Groupe "THYREL" sprint 5
- Rapport de travail Groupe "THYREL" sprint 6
- Rapport de travail Groupe "THYREL" sprint 7
- Rapport de travail Groupe "THYREL" sprint 8 - FINAL