Showing posts with label css. Show all posts
Showing posts with label css. Show all posts

How to Create a Bullet List with Material UI in React

Material UI is a popular library for building user interfaces in React. One of the common UI elements is a bullet list, which allows you to display a list of items with bullets. In this blog, we will explore how to create a bullet list using Material UI with sample code and examples.

Creating a Material UI Bullet List

To create a bullet list using Material UI, we can use the List and ListItem components. Here's an example:

import React from 'react'; import { List, ListItem, ListItemText } from '@material-ui/core'; function MyBulletList() { return ( <List> <ListItem> <ListItemText primary="Item 1" /> </ListItem> <ListItem> <ListItemText primary="Item 2" /> </ListItem> <ListItem> <ListItemText primary="Item 3" /> </ListItem> </List> ); }

In this example, we import the necessary components from Material UI (List, ListItem, and ListItemText) and use them to create a list with three items. The primary prop on ListItemText is used to display the text for each item.

Customizing a Material UI Bullet List

We can customize the appearance of the bullet list by using different Material UI props. Here are some examples:

  • dense: reduces the vertical padding of the list items.
  • disablePadding: removes the padding around the entire list.
  • divider: adds a divider between each list item.
  • secondary: displays secondary text for each list item.

Here's an example of a bullet list with these customizations:

import React from 'react'; import { List, ListItem, ListItemText } from '@material-ui/core'; function MyCustomBulletList() { return ( <List dense disablePadding> <ListItem divider> <ListItemText primary="Item 1" secondary="Secondary text" /> </ListItem> <ListItem divider> <ListItemText primary="Item 2" /> </ListItem> <ListItem divider> <ListItemText primary="Item 3" /> </ListItem> </List> ); }

In this example, we use the dense and disablePadding props to reduce the vertical padding and remove the padding around the entire list, respectively. We also use the divider prop on each ListItem to add a divider between each list item. Finally, we use the secondary prop on the first ListItemText to display secondary text for that item.

Conclusion

In this blog, we explored how to create a bullet list using Material UI in React, and how to customize the appearance of the list using different Material UI props. With these examples and the Material UI documentation, you can create bullet lists that fit your UI design and functionality needs.

Create social media icon using HTML & CSS

For creating social media icon we need to write html code with implementation of font-awesome library on html page:

Html Code:

<html>
<head>
<title>Social Media Icon Example</title>
<!-- Adding font awesome icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<a href="#" class="fa fa-facebook"></a>
<a href="#" class="fa fa-twitter"></a>
<a href="#" class="fa fa-google"></a>
<a href="#" class="fa fa-linkedin"></a>
<a href="#" class="fa fa-youtube"></a>
<a href="#" class="fa fa-instagram"></a>
<a href="#" class="fa fa-whatsapp"></a>
<a href="#" class="fa fa-pinterest"></a>
<a href="#" class="fa fa-snapchat-ghost"></a>
<a href="#" class="fa fa-skype"></a>
<a href="#" class="fa fa-github"></a>
<a href="#" class="fa fa-dribbble"></a>
<a href="#" class="fa fa-vimeo"></a>
<a href="#" class="fa fa-foursquare"></a>
<a href="#" class="fa fa-stumbleupon"></a>
<a href="#" class="fa fa-flickr"></a>
<a href="#" class="fa fa-yahoo"></a>
<a href="#" class="fa fa-reddit"></a>
<a href="#" class="fa fa-rss"></a>
</body>
</html>

As we included almost all social icons code in above HTML code but it will create a sober output like below :
simple_social_icon

For styling, we need to add style tag and write own custom CSS for that. and for styling the social media icon matching with their original logo color. 

Css code

<style>
.fa {  
  width: 25px;
  padding: 20px;
  font-size: 25px;
  text-align: center;
  text-decoration: none;
  margin: 5px 2px;
  color: white;
}

.fa:hover {
    opacity: 0.7;
}

.fa-facebook {
  background: #3B5998;
}

.fa-twitter {
  background: #55ACEE;
}

.fa-google {
  background: #dd4b39;
}

.fa-linkedin {
  background: #007bb5;
}

.fa-youtube {
  background: #bb0000;
}

.fa-instagram {
  background: #8a3ab9;
}

.fa-whatsapp {
  background: #4FCE5D;
}

.fa-pinterest {
  background: #cb2027;
}

.fa-snapchat-ghost {
  background: #fffc00;  
  text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}

.fa-skype {
  background: #00aff0;
}

.fa-github {
  background: #000000;
}

.fa-dribbble {
  background: #ea4c89;
}

.fa-vimeo {
  background: #45bbff;
}

.fa-foursquare {
  background: #45bbff;
}

.fa-stumbleupon {
  background: #eb4924;
}

.fa-flickr {
  background: #f40083;
}

.fa-yahoo {
  background: #430297;
}

.fa-reddit {
  background: #ff5700;
}

.fa-rss {
  background: #ff6600;
}
</style>

You have to use the above CSS code into the head tag of the HTML just below to the font awesome library link. after adding output will look like below when you run the code in the browser.

square_social_icon
And if you want this icon looks in round type then you just have added one line in the style code

i.e.
<style>
.fa {  
  .....
  .....
  border-radius: 50%;
}

....
....
</style>

Then the output will look like below 


round_social_icon



Or you can modify the stylings of the icons by changing into the CSS of the above-given code
i.e. suppose we want these icons to look sober and follow one color code for all.

So here the style tag code :

<style>
.fa {  
  width: 25px;
  padding: 20px;
  font-size: 25px;
  text-align: center;
  text-decoration: none;
  margin: 5px 2px;
  color: black;
  border: 2px solid black;
  border-radius: 50%; 
}
</style>

And the output of this is below :

round_black_&_ white_social_icon 

I hope that you all understand this concept properly. if not then feel to ask in the comment box I will definitely reply on the same.

Thank You !!!