01 - React JS: CSS Libraries - Semantic
React JS
CSS
Semantic
Introduction
React has a lot of CSS libraries, being Semantic one of these.
Getting started
Install the Semantic dependency
If you only want to use Semantic as a dependency and use the default theme, install semantic-ui-css
or semantic-ui-less
:
Importing components
In the main file, import the semantic-ui-css
library:
Import the components that you need from the semantic-ui-react
library:
Importing components from Semantic library
import { Card, Image } from 'semantic-ui-react';
// Now we can use the components from Semantic
const PersonCard = ({person}) => (
<Card>
<Image src={person.image} wrapped ui={false} />
<Card.Content>
<Card.Header>{`${person.name} + " " + ${person.surname}`}</Card.Header>
<Card.Meta>
<span className='age'>Age: {person.age}</span>
</Card.Meta>
<Card.Description>
Job: {person.job}
</Card.Description>
</Card.Content>
<Card.Content extra>
<a>
<Icon name='user' />
{person.friends} friends
</a>
</Card.Content>
</Card>
);
// Export the PersonCard object
export default PersonCard
After that, the component PersonCard
is reusable in any other React component: