# Simple button

This guide shows how to build a simple button component containing only a label and a link

**Do you have suggestions?:**
[Join our community](https://hygraph-community.slack.com) to suggest new recipe ideas!

This guide shows how to build a simple button component containing only a label and a link.

This is the simplest button component that you can create using Hygraph. It will let you add a URL and text for your button.

![Simple button component with fields](https://hygraph.com/images/docs/recipes/buttons/simple-button-component-fields.png)

## Prerequisites

- `REQUIRED:` You need to have a Hygraph account. If you don't have one, [<b>you can sign up here.</b>](https://app.hygraph.com/signup)
- `REQUIRED:` You need to have a Hygraph project.
  - `OPTION 1:` [<b>Create a project.</b>](https://hygraph.com/docs/getting-started/quickstart#create-a-project) This is the way to go if you want to follow the entire tutorial for learning purposes.
  - `OPTION 2:` [Clone the cookbook project.](https://hygraph.com/docs/recipes/buttons/button-simple#clone-project) This is the way to go if you're curious about how the buttons are made but don't want to follow the step-by-step creation process. This project contains the entire **Buttons Cookbook** so you can compare them, or look into what instances they contain.
  - `OPTION 3:` **Use an existing project of yours.** If you have a project already and want to add this button to it, this is the way to go. In this case, you may need to adjust parts of the tutorial to your own project schema.

**Note:**

- Take [<b>plan limits</b>](https://hygraph.com/pricing) into consideration when adding a recipe to your own project.
- Are you new to Hygraph? You may want to check out our [<b>Getting Started Tutorial!</b>](https://hygraph.com/docs/getting-started/tutorial/tutorial-overview)

## Core concepts

In this guide, you'll work with components and basic component fields. Let's look into these concepts:

- **Component**: a predefined set of fields that can be reused across models and content entries. You can think of a component as a flexible, reusable template: you define the fields that will be used inside a component once, and then fill them with different content every time you use it in a content entry.

- **Basic component field**: a component is a special field type in your Hygraph schema that defines which components of which type can be used in a model. Component fields can be of basic or modular types. A **basic component field** can only have one component attached to it. You can limit the number of component instances to one, or allow multiple component instances to be added in the content entry.

## What you can do

This guide offers two paths:

- [Path 1:](https://hygraph.com/docs/recipes/buttons/button-simple/#step-by-step-guide) Use this guide to create a simple button component that you can reuse across different models in your Hygraph projects.
- [Path 2:](https://hygraph.com/docs/recipes/buttons/button-simple/#clone-project) Clone the project that contains the entire **Buttons cookbook** to compare the different button configurations without having to clone multiple projects.

## Clone project

We have prepared a project that contains the entire **Buttons cookbook**:

[Clone this project](https://app.hygraph.com/clone/b6639ee932124165991e4be553f070b2?name=Hygraph%20Recipes%20-%20Buttons)

This cookbook contains all the recipes we have so far to create buttons, so you can compare the different button configurations without having to clone multiple projects.

To find this particular recipe in the cookbook project, navigate to the schema and look for **"Simple button"**.

This project also contains a demo model that includes all the button components as basic components, as well as a modular component that you can use as a button type selector.

## Step-by-step guide

[Video](https://www.youtube.com/watch?v=2FVytN1Sy5s)

To build our **simple button component**, let's navigate to the Schema of our Hygraph project and click `+Add` next to **Components**.

The first step is to create the component itself. We'll use the following information:

| Field         | Input         |
| ------------- | ------------- |
| Display Name  | Simple button |
| API ID        | SimpleButton  |
| API ID Plural | SimpleButtons |

We'll click `Add component` to save. 

We can now start adding instances to this component.

Let's start with a `Single line text` field, which will be the label of our button. We'll find it on the **Add fields** right sidebar, click on it, and use the following information:

| Field                         | Input                        |
| ----------------------------- | ---------------------------- |
| Display Name                  | Text                         |
| API ID                        | text                         |
| `Use as title field` checkbox | Leave this checkbox selected |
| `Localize field` checkbox     | Leave this checkbox selected |

We'll click `Add` to save.

Finally, let's add a `Slug` field, which will be our button URL. We'll find it on the **Add fields** right sidebar, click on it, and use the following information:

| Tab         | Field                               | Input                                                                                                                                                                        |
| ----------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Settings    | Display Name                        | URL                                                                                                                                                                          |
| Settings    | API ID                              | url                                                                                                                                                                          |
| Settings    | `Lowercase` checkbox                | Leave this checkbox selected                                                                                                                                                 |
| Validations | `Set field as unique` checkbox      | Leave this checkbox selected                                                                                                                                                 |
| Validations | `Match a specific pattern` checkbox | Leave this checkbox selected, and use the dropdown to select the `URL` pattern. Write "Input value does not match the expected format." in the `Custom error message` field. |

We'll click `Add` to save.

This is how you build a simple button component in Hygraph. You could add this component to different models in your schema.

![Simple button component with fields](https://hygraph.com/images/docs/recipes/buttons/simple-button-component-fields.png)

This guide helped you create the schema element yourself. Alternatively, you can clone a project containing all our button recipes.

Check out the next document section for that!

## Useful links

- [Components documentation](https://hygraph.com/docs/developer-guides/schema/components)

**Would you like to know more?:**
We have more resources for you!

This is the simplest button component that you can create using Hygraph. If you want to try out something more complex, we have a [button with social links](https://hygraph.com/docs/recipes/buttons/button-socials/) and a [styled button](https://hygraph.com/docs/recipes/buttons/button-link-styled/) for you to look into!

**Do you have suggestions?:**
[Join our community](https://hygraph-community.slack.com) to suggest new recipe ideas!
