I want to display only USA states as a select drop-down in custom phtml in Magento2.2.5?

Any help would be appreciated.


1 Answer 1


Add following code in your block class


    private $directoryData;

    public function __construct(
        \Magento\Directory\Block\Data $directoryData
    ) {
        $this->directoryData = $directoryData;

    public function getStates()
        return $this->directoryData->getRegionHtmlSelect();

Add following code in your PHTML file


echo $block->getStates();

Extra Notes:

You can use following code to get the complete data.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$states = $objectManager->create('Magento\Directory\Model\RegionFactory')
echo "<pre>";

after get dropdown list

<?php foreach ($states as $_state):?>
  <option value="<?php echo $_state->getCode();?>"><?php echo $_state->getName();?></option>
  <?php endforeach;?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.