RGB color picker using HTML & Bootstrap
Tags: webdev, beginners, html
Published: 2022-04-03 07:45:08

Today, I have created a RGB color picker using the HTML and Bootstrap. It was kind of fun and completed this within the 10 minutes of the development. 

Here is the LIVE [DEMO](https://ephemeral-starship-845e9e.netlify.app/)

## Technologies that used to build this demo

1. HTML
2. CSS (Inline)
3. Bootstrap 5
4. Javascript(A few lines)

## Code snippet
Here is the link of the code snippet if you wanted to have a look at the code

```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RGB Color Chooser</title>
    <!-- CSS only -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body style="background-color: black;">
    <header>
        <h1 class="text-center my-4 font-monospace text-white">RGB COLOR PICKER</h1>
    </header>
    <div class="container">
        <div class="row">
            <div class="col-md-4"></div>
            <div id="result" class="shadow rounded col-md-4 d-flex justify-content-center p-5 my-5" style="background-color: rgb(127,127,127);">
                
            </div>
            <div class="col-md-4"></div>
        </div>
        <div class="row">
            <div class="col-md-4 col-lg-4 p-5">
                <p class="text-center text-white">RED</p>
                <input type="range" class="form-range" min="0" max="255" step="1" id="customRange1" oninput='OutputIdRed.value = customRange1.value' onchange="changebackground()">
                <output class="text-center text-white" style="display: block;" id="OutputIdRed">127</output>
            </div>
            <div class="col-md-4 col-lg-4 p-5">
                <p class="text-center text-white">GREEN</p>
                <input type="range" class="form-range" min="0" max="255" step="1" id="customRange2" oninput='OutputIdGreen.value = customRange2.value' onchange="changebackground()">
                <output class="text-center text-white" style="display: block;" id="OutputIdGreen">127</output>
            </div>
            <div class="col-md-4 col-lg-4 p-5">
                <p class="text-center text-white">BLUE</p>
                <input type="range" class="form-range" min="0" max="255" step="1" id="customRange3" oninput='OutputIdBlue.value = customRange3.value' onchange="changebackground()">
                <output class="text-center text-white" style="display: block;" id="OutputIdBlue">127</output>
            </div>
        </div>
    </div>

    <script>

        function changebackground(){
	        document.getElementById('result').style.backgroundColor = 'rgb(' + document.getElementById("OutputIdRed").value + ',' + document.getElementById("OutputIdGreen").value + ',' + document.getElementById("OutputIdBlue").value + ')';
        }
    </script>
</body>
</html>
```

## Key Points to learn with this demo

- Bootstraps Classes
- Display Scroll value without using the javascript. 

So If you have checked the code, 
```
<input type="range" class="form-range" min="0" max="255" step="1" id="customRange1" oninput='OutputIdRed.value = customRange1.value' onchange="changebackground()">
<output class="text-center text-white" style="display: block;" id="OutputIdRed">127</output>

```
So here we are showing the scroll value that user has selected. So for that we have used the **oninput** field and set the user selected value in the **output** field. 

**Conclusion:**
Today, We have created a small demo where user can see the actual color based on the RGB values. We have created that demo using the HTML and Bootstrap. Also we have covered the key points that we can learn from this small demo which has developed within the 10 minutes😀. Hope you liked it and learn something new today. 

I'm also posting some useful content on twitter. So You guys can follow me there. [Link](https://twitter.com/dhruv_rajkotia)