Written by: Geoffrey Callaghan

create a contact form with Materialize CSS

Create A Contact Form With Materialize Css

Certainly! Below is a contact form using Materialize CSS along with FabForm for styling and functionality:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contact Form</title>
    <!-- Materialize CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
    <!-- FabForm -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fabform/dist/css/fabform.min.css">
</head>
<body>

<div class="container">
    <div class="row">
        <div class="col s12 m6 offset-m3">
            <form id="contactForm" class="fabform">
                <div class="card">
                    <div class="card-content">
                        <span class="card-title">Contact Us</span>
                        <div class="input-field">
                            <input id="name" name="name" type="text" class="validate" required>
                            <label for="name">Name</label>
                        </div>
                        <div class="input-field">
                            <input id="email" name="email" type="email" class="validate" required>
                            <label for="email">Email</label>
                        </div>
                        <div class="input-field">
                            <textarea id="message" name="message" class="materialize-textarea validate" required></textarea>
                            <label for="message">Message</label>
                        </div>
                    </div>
                    <div class="card-action">
                        <button type="submit" class="waves-effect waves-light btn">Submit</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- Materialize JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<!-- FabForm -->
<script src="https://cdn.jsdelivr.net/npm/fabform/dist/js/fabform.min.js"></script>
<script>
    // Initialize FabForm
    const form = document.getElementById('contactForm');
    new FabForm(form);
</script>

</body>
</html>

This form includes fields for name, email, and message, along with a submit button. FabForm handles the styling and validation, while Materialize CSS provides the overall styling of the form. Feel free to adjust the styles and structure as needed.