Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <h1>Styling a Bootstrap Button for File Uploads with Filestack</h1>
  This CodePen provides an example implementation of the code
  mentioned on the Filestack blog post here:
  <a href="https://blog.filestack.com/tutorials/beautiful-bootstrap-file-upload/"
  Before you can run the Filestack File Picker, you'll need
  to enter your <a target="_blank" href="https://dev.filestack.com/signup/trial/">Filestack API Key</a>.
  <button id="set">Set my API Key</button>
  <span id="fsapikey"></span>
  2. Check out these Bootstrap Buttons!<br/>
  <button id="standard_bs_button"
          class="btn">A plain Bootstrap Button</button>
  <button id="bs_button"
          class="btn btn-primary">Primary Bootstrap Button</button>
  <button class="btn btn-filestack">We can style it, too!</button>

<h2>Our final result:</h2>

<p id="final_result">
  <button id="final_button"
          class="btn btn-filestack btn-widget">Pick a File</button>

  Read more on the Filestack blog:
  <a href="https://blog.filestack.com/">https://blog.filestack.com/</a>
<p id="clear">
  [<a href="#">Clear my APIKEY from localStorage</a>]

        Example Styles

Read these comments for some additional context, or scroll to the bottom of this box to view the styles.

/* Where's Bootstrap?!
CodePen allows you to import external resources via configuration options, and those do not display in the code boxes here. Click on the gear icon next to the words CSS (SCSS) in this code window, and scroll down to where you see "Add External Stylesheets/Pens" in the CSS tab. See that text field with `https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css` listed? That's where Bootstrap is being imported. Well, the CSS at least. That's all we need for this example! The rest of what is here is custom styles to support the blog post here: [link]

// This looks weird!
/* Yup. This isn't CSS, but it is very close. This is SCSS. We didn't go crazy with it, though - you can just substitute the SCSS variables used in the body of the styles with actual colors and you'll have "regular CSS" if desired.

/* Feel free to change the background-color and border-color to fit your website's color scheme */
.btn-filestack {
 background-color: black;
 border-color: #ee4632;
.btn-filestack:hover {
 color: #ee4632;
.btn-filestack:hover {
 //background-color: #330000;
 box-shadow: 0 2px 2px 0 rgba(256,256,256,0.24), 0 6px 6px 0 rgba(120,120,120,0.19);
.btn.btn-filestack:focus {
 color: #fff;
 outline: none;

.btn-widget, .btn-widget:active {
  font-family: "Open Sans", sans-serif;
  font-size: 12px;
  font-weight: 600;
  border-radius: 17px;
  padding: 4px 30px 5px 40px;
  height: 34px;
  /* Set the path of your logo */
  background-image: url('https://www.filestack.com/favicon.ico');
  background-size: 16px 16px;
  background-position: 16px 8px;
  background-repeat: no-repeat;
  line-height: 23px;

.btn-widget::after {
  position: relative;
  content: "\21a9";
  color: rgb(239,74,37);
  top: -0px;
  right: -11px;
  width: 1px;
  height: 12px;
  background: 0 0 no-repeat;

/* Additions */
body {
  background: #181325;
  color: #ee4632;
  font-family: monospace;
  padding: 12px 12px 24px 24px;
  text-align: center;
  width: 80%;
h1 {
  font-size: x-large;
h2 {
  font-size: large;
h1, h2 {
  font-family: Verdana;
  padding: 12px;
  color: white;
#final_result {
  margin: auto;
  padding: 42px;
  width: 80%;
  border: solid 1px red;
#clear {
  font-size: small;

              // Example JavaScript

These styles and behaviors don't require JS to work.
The File Picker does, so you'll see a little code that
calls that into action.

There's also a little JS code at the end that handles
different Filestack API Keys.
var apiKey = localStorage.getItem("apiKey");
// That line needs to be above the others so your APIKEY gets used

var fs_button = document.querySelector("#final_button");
fs_button.addEventListener("click", function() {
  var client = filestack
  .init(apiKey) // That's where we're using the localStorage <<--
    fromSources: [
      // 'imagesearch',

API Keys are just for you. While security is not based on keeping your API key a secret (there's an actual 'secret' for that), it can be confusing to share code examples that depend on that key when you're supposed to be using your very own key. To help keep that all sorted out, this code creates one step you need to do before this project can run: enter your Filestack API key. It is based on the official recommendations found here:

var s_button = document.querySelector("#set");
var div = document.querySelector("#fsapikey");
var apiKey = localStorage.getItem("apiKey");
if (!apiKey) {
  div.innerHTML = "";
} else {
  div.innerHTML = "My Filestack APIKEY: " + apiKey;

s_button.addEventListener("click", function() {
  apiKey = prompt("Enter API Key:");
  var myApiKey = localStorage.setItem("apiKey", apiKey);
  div.innerHTML = "Filestack APIKEY: " + myApiKey;
var clearlink = document.querySelector("#clear").addEventListener("click", function(){
  if( apiKey ){
    div.innerHTML = "";

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.