> For the complete documentation index, see [llms.txt](https://2600hz.gitbook.io/sds/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://2600hz.gitbook.io/sds/sds-components/form-controls/credit-card/code.md).

# Code

| Props           | Data Type                                            | Required             |
| --------------- | ---------------------------------------------------- | -------------------- |
| name            | string                                               | :white\_check\_mark: |
| number          | string                                               | :white\_check\_mark: |
| expiry          | string                                               | :white\_check\_mark: |
| cvc             | string                                               | :white\_check\_mark: |
| focused         | <p>string<br>('name', 'number', 'expiry', 'cvc')</p> | :white\_check\_mark: |
| namePlaceholder | boolean                                              | :x:                  |
| accepdCards     | boolean                                              | :x:                  |

{% hint style="info" %}
This component should be used together with CreditCardName, CreditCardNumber, CreditCardCVC, CreditCardDate components.
{% endhint %}

### Complement Components

#### CreditCardName, CreditCardNumber, CreditCardCVC, CreditCardDate

| Props        | Data Type | Required             |
| ------------ | --------- | -------------------- |
| value        | string    | :white\_check\_mark: |
| className    | string    | :x:                  |
| id           | string    | :white\_check\_mark: |
| name         | string    | :x:                  |
| label        | string    | :x:                  |
| info         | string    | :x:                  |
| helptext     | string    | :x:                  |
| error        | boolean   | :x:                  |
| errorMessage | string    | :x:                  |
| disabled     | boolean   | :x:                  |
| readOnly     | boolean   | :x:                  |
| onBlur       | function  | :x:                  |
| onChange     | function  | :x:                  |
| onChange     | function  | :x:                  |

{% hint style="info" %}
These four components work exactly like the TextInput and NumberInput components removing a couple of extra features to delimitate the specific experience to give to the user by using this inputs.
{% endhint %}

{% hint style="info" %}
Also the tokens used for these components are the same that we're using for the TextInput and NumberInput components.
{% endhint %}

### How To Use

The main component is CreditCard, which is going to receive through the other CreditCard input components the data to perform the animations and interactions expected.

![](/files/fNNH8AJ1AGR3HmbYzSfg)

![](/files/hyFK8koeb0Hu7G18fhie)

![](/files/ux3XUKN8yVe7ZcosHeS6)

### Example

```tsx
import React, { useState } from 'react';
import {
  CreditCard,
  CreditCardNumber,
  CreditCardName,
  CreditCardDate,
  CreditCardCVC,
  Text
} from '@2600hz/sds-react-components';
import './app.scss';

const App = () => {
  const [focusedData, setFocusedData] = useState<
    'name' | 'number' | 'cvc' | 'expiry'
  >('name');
  
  const [cardData, setCardData] = useState({
    name: '',
    number: '',
    cvc: '',
    expiry: ''
  });
  
  const focusElement(id){
    switch (id) {
      case 'name':
        setFocusedData('name');
        break;
      case 'number':
        setFocusedData('number');
        break;
      case 'cvc':
        setFocusedData('cvc');
        break;
      case 'expiry':
        setFocusedData('expiry');
        break;
      default:
        setFocusedData('name');
        break;
    }
  }

  const change = (e: any) => {
    const { value, id } = e;
    focusElement(id);
    setCardData((prevState) => ({ ...prevState, [id]: value }));
  };

  const focus = (e: any) => {
    const { id } = e;
    focusElement(id);
  };

  return (
    <div>
      <div className="form">
        <Text.h2 textStyle="Heading1">Credit Card Data</Text.h2>
        <CreditCardName
          id="name"
          value={cardData.name}
          onFocus={focus}
          onChange={change}
        />
        <CreditCardNumber
          id="number"
          value={cardData.number}
          onFocus={focus}
          onChange={change}
        />
        <CreditCardDate
          id="expiry"
          value={cardData.expiry}
          onFocus={focus}
          onChange={change}
        />
        <CreditCardCVC
          id="cvc"
          value={cardData.cvc}
          onFocus={focus}
          onChange={change}
        />
      </div>
      <CreditCard
        name={cardData.name}
        number={cardData.number}
        expiry={cardData.expiry}
        cvc={cardData.cvc}
        focused={focusedData}
      />
    </div>
  );
};

export default App;
```

## Live Demo

For detailed code usage documentation, see the Storybooks for each framework below.

#### React

{% embed url="<https://sipster-react-component-storybook.netlify.app/?path=/story/form-controls-credit-card-controls--credit-card-controls>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://2600hz.gitbook.io/sds/sds-components/form-controls/credit-card/code.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
