Categories We Write About

Build a writing prompt randomizer

Here’s a basic writing prompt randomizer idea you can use in a web app or as a script in a development project. I’ll break it into key parts:

Writing Prompt Randomizer (JavaScript)

This code will create a random writing prompt generator that you can use in your projects. It selects a random prompt from a predefined list and outputs it each time the button is clicked.

html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Writing Prompt Randomizer</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f4f4f9; } .container { text-align: center; padding: 30px; background-color: white; border-radius: 8px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); } button { padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; } button:hover { background-color: #0056b3; } #prompt { margin-top: 20px; font-size: 18px; font-style: italic; } </style> </head> <body> <div class="container"> <h1>Writing Prompt Randomizer</h1> <button onclick="generatePrompt()">Get a New Prompt</button> <p id="prompt">Click the button to get a new writing prompt.</p> </div> <script> const prompts = [ "Write about a world where humans never discovered fire.", "Imagine a conversation between your future self and your past self.", "Write about a moment when you felt completely out of place.", "Write a story from the perspective of a tree watching the world change.", "Describe a dream you had that left a lasting impression on you.", "What would happen if animals could speak for just one day? Write about it.", "Write a letter to your future self 10 years from now.", "Write a scene where two characters meet but can't speak the same language.", "Describe a place that is both beautiful and eerie at the same time.", "Write a story where technology stops working, and the world must adapt." ]; function generatePrompt() { const randomIndex = Math.floor(Math.random() * prompts.length); const prompt = prompts[randomIndex]; document.getElementById('prompt').textContent = prompt; } </script> </body> </html>

How it works:

  • The prompts array contains a list of writing prompts.

  • The generatePrompt() function is called when you click the button. It picks a random prompt from the array and displays it on the webpage.

  • The HTML sets up a button and an area to show the prompt, while the CSS adds basic styling.

You can copy this code into an HTML file, and it will create a simple page where you can click the button to get a new writing prompt. Would you like to expand or customize it further?

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories We Write About